New functions to retrieve certificate from SSL_CTX

New functions to retrieve current certificate or private key
from an SSL_CTX.

Constify SSL_get_private_key().
This commit is contained in:
Dr. Stephen Henson
2013-11-18 18:49:46 +00:00
parent 60aeb18750
commit a25f9adc77
3 changed files with 26 additions and 5 deletions

View File

@@ -3103,7 +3103,6 @@ void ssl_clear_cipher_ctx(SSL *s)
#endif
}
/* Fix this function so that it takes an optional type parameter */
X509 *SSL_get_certificate(const SSL *s)
{
if (s->cert != NULL)
@@ -3112,8 +3111,7 @@ X509 *SSL_get_certificate(const SSL *s)
return(NULL);
}
/* Fix this function so that it takes an optional type parameter */
EVP_PKEY *SSL_get_privatekey(SSL *s)
EVP_PKEY *SSL_get_privatekey(const SSL *s)
{
if (s->cert != NULL)
return(s->cert->key->privatekey);
@@ -3121,6 +3119,22 @@ EVP_PKEY *SSL_get_privatekey(SSL *s)
return(NULL);
}
X509 *SSL_CTX_get0_certificate(const SSL_CTX *ctx)
{
if (ctx->cert != NULL)
return ctx->cert->key->x509;
else
return NULL;
}
EVP_PKEY *SSL_CTX_get0_privatekey(const SSL_CTX *ctx)
{
if (ctx->cert != NULL)
return ctx->cert->key->privatekey;
else
return NULL ;
}
const SSL_CIPHER *SSL_get_current_cipher(const SSL *s)
{
if ((s->session != NULL) && (s->session->cipher != NULL))