If anyone can help me, it would be greatly appreciated.  I am trying to take the peer certificate passed from the server:
 
    peer = SSL_get_peer_certificate(ssl);
 
//    if I have received a certificate chain
//    I use the deepest certificate in the chain
 
    if (peer_chn = SSL_get_peer_cert_chain(s_ctx->ssl))
    {
        got_a_chain = 1;
    }
   
    ...
   
    if (got_a_chain && ((CAindex = sk_X509_num(peer_chn)-1) > 0))
    {
        peer = X509_dup( sk_X509_value(peer_chn,CAindex) );
    }
 
and encode it and save it to my hashed directory of stored certificates.  I am encoding and hashing the name correctly but when it is time to retrieve the stored certificate I am receiving an error of 21 (the leaf certificate can't be verified).  If I trace into x509_vfy it looks as though I need a self-signed certificate.  The certificate that is stored is not self-signed - it is ultimately the same certificate that I am receiving again.  Am I trying to store the wrong thing?  If so, does anyone know what I should be storing?  Any ideas would help a lot.  Thank you,
 
Shane

Reply via email to