make sure key used for signing _can_ sign

This commit is contained in:
Karl-Heinz Zimmer 2002-07-02 16:32:29 +00:00
parent abf4c3bb50
commit 59c6205c78

View File

@ -1118,18 +1118,28 @@ bool signMessage( const char* cleartext,
/* select the signer's key if provided */ /* select the signer's key if provided */
if (certificate != 0) { if (certificate != 0) {
err = gpgme_op_keylist_start(ctx, certificate, 0); err = gpgme_op_keylist_start(ctx, certificate, 0);
if (err == GPGME_No_Error) { while (err == GPGME_No_Error) {
/* we only support one signer for now */
err = gpgme_op_keylist_next(ctx, &rKey); err = gpgme_op_keylist_next(ctx, &rKey);
if (err == GPGME_No_Error) { if (err == GPGME_No_Error) {
unsigned long u;
u = gpgme_key_get_ulong_attr(rKey, GPGME_ATTR_CAN_SIGN, 0, 0);
if( u ) {
// const char* s;
// s = gpgme_key_get_string_attr(rKey, GPGME_ATTR_FPR, 0, 0);
// fprintf( stderr, "gpgmeplug signMessage signing with key: %s\n", s );
/* clear existing signers */ /* clear existing signers */
gpgme_signers_clear(ctx); gpgme_signers_clear(ctx);
/* set the signing key */ /* set the signing key */
gpgme_signers_add(ctx, rKey); gpgme_signers_add(ctx, rKey);
/* we only support one signer for now */
break;
}
}
} }
gpgme_op_keylist_end(ctx); gpgme_op_keylist_end(ctx);
} }
}
/* PENDING(g10) Implement this /* PENDING(g10) Implement this
@ -2584,7 +2594,6 @@ bool checkMessageSignature( char** cleartext,
sigmeta->extended_info[sig_idx].userid_num = attr_ulong; sigmeta->extended_info[sig_idx].userid_num = attr_ulong;
/* extract the length */ /* extract the length */
attr_ulong = gpgme_key_get_ulong_attr(key, GPGME_ATTR_LEN, 0, 0);
sigmeta->extended_info[sig_idx].keylen = attr_ulong; sigmeta->extended_info[sig_idx].keylen = attr_ulong;
/* extract the creation time of the key */ /* extract the creation time of the key */