diff options
| author | Karl-Heinz Zimmer <[email protected]> | 2002-06-26 08:04:43 +0000 | 
|---|---|---|
| committer | Karl-Heinz Zimmer <[email protected]> | 2002-06-26 08:04:43 +0000 | 
| commit | 73f47e40b1429a4683e7c0e2e795ac8563d84edf (patch) | |
| tree | f09a8f2c43fc6e7abce64e1448e4a489b0763b6c /gpgmeplug/gpgmeplug.c | |
| parent | IMPORTANT BUGFIX: Avoid random crashes in findCertificates. (This also fixe... (diff) | |
| download | gpgme-73f47e40b1429a4683e7c0e2e795ac8563d84edf.tar.gz gpgme-73f47e40b1429a4683e7c0e2e795ac8563d84edf.zip | |
Make the signatureCertificateDaysLeftToExpiry() work as expected.
Diffstat (limited to '')
| -rw-r--r-- | gpgmeplug/gpgmeplug.c | 76 | 
1 files changed, 72 insertions, 4 deletions
| diff --git a/gpgmeplug/gpgmeplug.c b/gpgmeplug/gpgmeplug.c index 7e928355..3540a4d2 100644 --- a/gpgmeplug/gpgmeplug.c +++ b/gpgmeplug/gpgmeplug.c @@ -496,8 +496,6 @@ bool signatureCertificateExpiryNearWarning( void )  int signatureCertificateDaysLeftToExpiry( const char* certificate )  { -  // pending (khz): make this work! -  /*    GpgmeCtx ctx;    GpgmeError err;    GpgmeKey rKey; @@ -521,10 +519,12 @@ int signatureCertificateDaysLeftToExpiry( const char* certificate )      }    }    gpgme_release( ctx ); +     +  /*  +  fprintf( stderr, "gpgmeplug signatureCertificateDaysLeftToExpiry returned %d\n", daysLeft ); +  */    return daysLeft; -  */ -  return 10;  } @@ -555,6 +555,40 @@ int caCertificateDaysLeftToExpiry( const char* certificate )         CA certificate for the certificate specified in the parameter         certificate expires.      */ +  /* +  GpgmeCtx ctx; +  GpgmeError err; +  GpgmeKey rKey; +  time_t daysLeft = 0; + +  gpgme_new( &ctx ); +  gpgme_set_protocol( ctx, GPGMEPLUG_PROTOCOL ); + +  err = gpgme_op_keylist_start( ctx, certificate, 0 ); +  if ( GPGME_No_Error == err ) { +    err = gpgme_op_keylist_next( ctx, &rKey ); +    gpgme_op_keylist_end( ctx ); +    if ( GPGME_No_Error == err ) { +      time_t expire_time = gpgme_key_get_ulong_attr( +                             rKey, +                              +??????????????????????? GPGME_ATTR_EXPIRE,  ??????????????????????? +                              +                             NULL, 0 ); +      time_t cur_time = time (NULL); +      daysLeft = expire_time - cur_time; +      // convert seconds into days +      daysLeft /= 43200; +      gpgme_key_release( rKey ); +    } +  } +  gpgme_release( ctx ); +     +    +  // fprintf( stderr, "gpgmeplug caCertificateDaysLeftToExpiry returned %d\n", daysLeft ); +  return daysLeft; +  */ +      return 10; /* dummy that triggers a warning in the MUA */  } @@ -585,6 +619,40 @@ int rootCertificateDaysLeftToExpiry( const char* certificate )         root certificate for the certificate specified in the parameter         certificate expires.      */ +  /* +  GpgmeCtx ctx; +  GpgmeError err; +  GpgmeKey rKey; +  time_t daysLeft = 0; + +  gpgme_new( &ctx ); +  gpgme_set_protocol( ctx, GPGMEPLUG_PROTOCOL ); + +  err = gpgme_op_keylist_start( ctx, certificate, 0 ); +  if ( GPGME_No_Error == err ) { +    err = gpgme_op_keylist_next( ctx, &rKey ); +    gpgme_op_keylist_end( ctx ); +    if ( GPGME_No_Error == err ) { +      time_t expire_time = gpgme_key_get_ulong_attr( +                             rKey, +                              +??????????????????????? GPGME_ATTR_EXPIRE,  ??????????????????????? +                              +                             NULL, 0 ); +      time_t cur_time = time (NULL); +      daysLeft = expire_time - cur_time; +      // convert seconds into days +      daysLeft /= 43200; +      gpgme_key_release( rKey ); +    } +  } +  gpgme_release( ctx ); +     +    +  // fprintf( stderr, "gpgmeplug rootCertificateDaysLeftToExpiry returned %d\n", daysLeft ); +  return daysLeft; +  */ +      return 10; /* dummy that triggers a warning in the MUA */  } | 
