aboutsummaryrefslogtreecommitdiffstats
path: root/gpgmeplug/gpgmeplug.c
diff options
context:
space:
mode:
Diffstat (limited to 'gpgmeplug/gpgmeplug.c')
-rw-r--r--gpgmeplug/gpgmeplug.c30
1 files changed, 16 insertions, 14 deletions
diff --git a/gpgmeplug/gpgmeplug.c b/gpgmeplug/gpgmeplug.c
index 404189d6..fe456ff6 100644
--- a/gpgmeplug/gpgmeplug.c
+++ b/gpgmeplug/gpgmeplug.c
@@ -545,7 +545,7 @@ int signatureCertificateDaysLeftToExpiry( const char* certificate )
GpgmeCtx ctx;
GpgmeError err;
GpgmeKey rKey;
- time_t daysLeft = 0;
+ int daysLeft = CRYPTPLUG_CERT_DOES_NEVER_EXPIRE;
gpgme_new( &ctx );
gpgme_set_protocol( ctx, GPGMEPLUG_PROTOCOL );
@@ -556,9 +556,14 @@ int signatureCertificateDaysLeftToExpiry( const char* certificate )
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 );
+ rKey, GPGME_ATTR_EXPIRE, NULL, 0 );
time_t cur_time = time (NULL);
- daysLeft = days_from_seconds(expire_time - cur_time);
+ if( cur_time > expire_time ) {
+ daysLeft = days_from_seconds(cur_time - expire_time);
+ daysLeft *= -1;
+ }
+ else
+ daysLeft = days_from_seconds(expire_time - cur_time);
gpgme_key_release( rKey );
}
}
@@ -830,7 +835,7 @@ int receiverCertificateDaysLeftToExpiry( const char* certificate )
GpgmeCtx ctx;
GpgmeError err;
GpgmeKey rKey;
- time_t daysLeft = 0;
+ int daysLeft = CRYPTPLUG_CERT_DOES_NEVER_EXPIRE;
gpgme_new( &ctx );
gpgme_set_protocol( ctx, GPGMEPLUG_PROTOCOL );
@@ -843,7 +848,12 @@ int receiverCertificateDaysLeftToExpiry( const char* certificate )
time_t expire_time = gpgme_key_get_ulong_attr(
rKey,GPGME_ATTR_EXPIRE, NULL, 0 );
time_t cur_time = time (NULL);
- daysLeft = days_from_seconds(expire_time - cur_time);
+ if( cur_time > expire_time ) {
+ daysLeft = days_from_seconds(cur_time - expire_time);
+ daysLeft *= -1;
+ }
+ else
+ daysLeft = days_from_seconds(expire_time - cur_time);
gpgme_key_release( rKey );
}
}
@@ -854,14 +864,6 @@ int receiverCertificateDaysLeftToExpiry( const char* certificate )
*/
return daysLeft;
-
-
-
- /* PENDING(g10)
- Please return the number of days that are left until the
- certificate specified in the parameter certificate expires.
- */
- return 10; /* dummy that triggers a warning in the MUA */
}
@@ -2362,7 +2364,7 @@ importCertificateFromMem( const char* data, size_t length , char** additional_in
}
if( count < 1 ) {
/* we didn't import anything?!? */
- fprintf( stderr, "gpgme_op_import_ext did not import any certificate\n", err );
+ fprintf( stderr, "gpgme_op_import_ext did not import any certificate\n" );
gpgme_data_release( keydata );
gpgme_release( ctx );
return -1; /* FIXME */