Victor, Thank you. I've managed to write code that does fingerprint verification like you suggested, and it seems to work.
-----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Victor Duchovni Sent: Wednesday, February 13, 2008 8:59 AM To: openssl-users@openssl.org Subject: Re: Direct trust in server certificate? On Tue, Feb 12, 2008 at 04:33:49PM -0500, Cooper, Andy wrote: > Now, on the client I'm trying to make sure that only the certificate > I've created is valid and that any other certificate is not valid. > What I'm seeing is that the client doesn't seem to care about the > server certificate as long as it has the CA certificate in its trusted > certificates file. The OpenSSL verification callbacks only (optionally) verify the certificate trust chain. Verifying that this is the right cert for a given destination is application code you have to write, as OpenSSL has no idea who you expected to connect to, or what your matching rules are. > Is there any way I can make the client ONLY accept the one and only > server certificate that I specify and deny other certificates issued > by the same certificate authority? As an example, see: http://www.postfix.org/TLS_README.html#client_tls_fprint the code to compare the peer cert against the expected fingerprint is something you need to provide. The X509_digest() routine allows you to obtain the peer certificate fingerprint. You could instead fingerprint just the public key, which will continue to work even if a new cert is issued for the same private/public key pair. int X509_pubkey_digest(const X509 *data,const EVP_MD *type, unsigned char *md, unsigned int *len); int X509_digest(const X509 *data,const EVP_MD *type, unsigned char *md, unsigned int *len); The "pubkey" version is less convenient for users. I am not aware of any standard command-line tools to print the pubkey fingerprint from an x509 file. The C API appears to have been added in 0.9.7. If you switch to verifying the fingerprint, you can entirely forgo the trust chain verification, it is no longer needed. Just use SSL_CTX_set_verify() with a callback that always returns 1. static int ok_cb(int preverify_ok, X509_STORE_CTX *x509_ctx) { return 1; } ... SSL_CTX_set_verify(ssl_ctx, SSL_VERIFY_NONE, ok_cb); ... -- Viktor. ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List openssl-users@openssl.org Automated List Manager [EMAIL PROTECTED] ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List openssl-users@openssl.org Automated List Manager [EMAIL PROTECTED]