openssl get certificate from SSL_CTX

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

openssl get certificate from SSL_CTX

radiatejava
I want to get the client certificate and the CA certificates that I
set to SSL_CTX. Is there any sample code to do this ? I have not been
successful so far. I set the certificate and CA certs this way.

char* cacertFile = "cacert.crt";
char* certFile = "client.crt";
char* keyFile = "client.key";

if (!SSL_CTX_load_verify_locations(ctx, cacertFile, NULL)) {
    std::cout << "cannot load cacerts" << std::endl;
} else {
    std::cout << "cacert loaded" << std::endl;
}

if (!SSL_CTX_use_certificate_file(ctx, certFile, SSL_FILETYPE_PEM)) {
    std::cout << "cannot load certfile" << std::endl;
} else {
    std::cout << "certfile loaded" << std::endl;
}

if (!SSL_CTX_use_PrivateKey_file(ctx, keyFile, SSL_FILETYPE_PEM)) {
    std::cout << "cannot load private key" << std::endl;
} else {
    std::cout << "private key loaded" << std::endl;
}

Later I want to see what is the client cert and CA certs. I am looking
for any example code to do this.

Thanks.
--
openssl-users mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users