aboutsummaryrefslogtreecommitdiff
path: root/src/daemon/https/tls/gnutls_cert.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/daemon/https/tls/gnutls_cert.c')
-rw-r--r--src/daemon/https/tls/gnutls_cert.c147
1 files changed, 0 insertions, 147 deletions
diff --git a/src/daemon/https/tls/gnutls_cert.c b/src/daemon/https/tls/gnutls_cert.c
index f5d657d4..f0357840 100644
--- a/src/daemon/https/tls/gnutls_cert.c
+++ b/src/daemon/https/tls/gnutls_cert.c
@@ -361,153 +361,6 @@ void MHD_gtls_certificate_server_set_retrieve_function
361 cred->server_get_cert_callback = func; 361 cred->server_get_cert_callback = func;
362} 362}
363 363
364/*-
365 * MHD__gnutls_x509_extract_certificate_activation_time - This function returns the peer's certificate activation time
366 * @cert: should contain an X.509 DER encoded certificate
367 *
368 * This function will return the certificate's activation time in UNIX time
369 * (ie seconds since 00:00:00 UTC January 1, 1970).
370 *
371 * Returns a (time_t) -1 in case of an error.
372 *
373 -*/
374static time_t
375MHD__gnutls_x509_get_raw_crt_activation_time (const MHD_gnutls_datum_t * cert)
376{
377 MHD_gnutls_x509_crt_t xcert;
378 time_t result;
379
380 result = MHD_gnutls_x509_crt_init (&xcert);
381 if (result < 0)
382 return (time_t) - 1;
383
384 result = MHD_gnutls_x509_crt_import (xcert, cert, GNUTLS_X509_FMT_DER);
385 if (result < 0)
386 {
387 MHD_gnutls_x509_crt_deinit (xcert);
388 return (time_t) - 1;
389 }
390
391 result = MHD_gnutls_x509_crt_get_activation_time (xcert);
392
393 MHD_gnutls_x509_crt_deinit (xcert);
394
395 return result;
396}
397
398/*-
399 * MHD_gnutls_x509_extract_certificate_expiration_time - This function returns the certificate's expiration time
400 * @cert: should contain an X.509 DER encoded certificate
401 *
402 * This function will return the certificate's expiration time in UNIX
403 * time (ie seconds since 00:00:00 UTC January 1, 1970). Returns a
404 *
405 * (time_t) -1 in case of an error.
406 *
407 -*/
408static time_t
409MHD__gnutls_x509_get_raw_crt_expiration_time (const MHD_gnutls_datum_t * cert)
410{
411 MHD_gnutls_x509_crt_t xcert;
412 time_t result;
413
414 result = MHD_gnutls_x509_crt_init (&xcert);
415 if (result < 0)
416 return (time_t) - 1;
417
418 result = MHD_gnutls_x509_crt_import (xcert, cert, GNUTLS_X509_FMT_DER);
419 if (result < 0)
420 {
421 MHD_gnutls_x509_crt_deinit (xcert);
422 return (time_t) - 1;
423 }
424
425 result = MHD_gnutls_x509_crt_get_expiration_time (xcert);
426
427 MHD_gnutls_x509_crt_deinit (xcert);
428
429 return result;
430}
431
432/**
433 * MHD_gtls_certificate_expiration_time_peers - This function returns the peer's certificate expiration time
434 * @session: is a gnutls session
435 *
436 * This function will return the peer's certificate expiration time.
437 *
438 * Returns: (time_t)-1 on error.
439 **/
440time_t
441MHD_gtls_certificate_expiration_time_peers (MHD_gtls_session_t session)
442{
443 cert_auth_info_t info;
444
445 CHECK_AUTH (MHD_GNUTLS_CRD_CERTIFICATE, GNUTLS_E_INVALID_REQUEST);
446
447 info = MHD_gtls_get_auth_info (session);
448 if (info == NULL)
449 {
450 return (time_t) - 1;
451 }
452
453 if (info->raw_certificate_list == NULL || info->ncerts == 0)
454 {
455 MHD_gnutls_assert ();
456 return (time_t) - 1;
457 }
458
459 switch (MHD_gnutls_certificate_type_get (session))
460 {
461 case MHD_GNUTLS_CRT_X509:
462 return
463 MHD__gnutls_x509_get_raw_crt_expiration_time (&info->
464 raw_certificate_list
465 [0]);
466 default:
467 return (time_t) - 1;
468 }
469}
470
471/**
472 * MHD_gtls_certificate_activation_time_peers - This function returns the peer's certificate activation time
473 * @session: is a gnutls session
474 *
475 * This function will return the peer's certificate activation time.
476 * This is the creation time for openpgp keys.
477 *
478 * Returns: (time_t)-1 on error.
479 **/
480time_t
481MHD_gtls_certificate_activation_time_peers (MHD_gtls_session_t session)
482{
483 cert_auth_info_t info;
484
485 CHECK_AUTH (MHD_GNUTLS_CRD_CERTIFICATE, GNUTLS_E_INVALID_REQUEST);
486
487 info = MHD_gtls_get_auth_info (session);
488 if (info == NULL)
489 {
490 return (time_t) - 1;
491 }
492
493 if (info->raw_certificate_list == NULL || info->ncerts == 0)
494 {
495 MHD_gnutls_assert ();
496 return (time_t) - 1;
497 }
498
499 switch (MHD_gnutls_certificate_type_get (session))
500 {
501 case MHD_GNUTLS_CRT_X509:
502 return
503 MHD__gnutls_x509_get_raw_crt_activation_time (&info->
504 raw_certificate_list
505 [0]);
506 default:
507 return (time_t) - 1;
508 }
509}
510
511int 364int
512MHD_gtls_raw_cert_to_gcert (MHD_gnutls_cert * gcert, 365MHD_gtls_raw_cert_to_gcert (MHD_gnutls_cert * gcert,
513 enum MHD_GNUTLS_CertificateType type, 366 enum MHD_GNUTLS_CertificateType type,