components/openssl: add empty fucntion to get peer certification and fix ref overflow

This commit is contained in:
dongheng 2016-09-22 17:20:07 +08:00
parent f796b4e58e
commit 18787fd4fc
4 changed files with 22 additions and 8 deletions

View file

@ -144,6 +144,8 @@ struct ssl_session_st {
long timeout;
long time;
X509 *peer;
};
struct X509_VERIFY_PARAM_st {

View file

@ -177,7 +177,7 @@ int SSL_CTX_use_PrivateKey_ASN1(int type, SSL_CTX *ctx,
if (!ret)
SSL_RET(failed2, "SSL_CTX_use_PrivateKey\n");
ctx->cert->pkey->ref++;
ctx->cert->pkey->ref = 1;
return 1;
@ -216,7 +216,7 @@ int SSL_use_PrivateKey_ASN1(int type, SSL *ssl,
if (!ret)
SSL_RET(failed2, "SSL_CTX_use_PrivateKey\n");
ssl->cert->pkey->ref++;
ssl->cert->pkey->ref = 1;
return 1;

View file

@ -218,7 +218,6 @@ int SSL_CTX_use_certificate_ASN1(SSL_CTX *ctx, int len,
{
int ret;
X509 *cert;
const unsigned char *pbuf;
cert = d2i_X509(&ctx->cert->x509, d, len);
if (!cert)
@ -228,7 +227,7 @@ int SSL_CTX_use_certificate_ASN1(SSL_CTX *ctx, int len,
if (!ret)
SSL_RET(failed2, "SSL_CTX_use_certificate\n");
ctx->cert->x509->ref++;
ctx->cert->x509->ref = 1;
return 1;
@ -266,7 +265,7 @@ int SSL_use_certificate_ASN1(SSL *ssl, int len,
if (!ret)
SSL_RET(failed2, "SSL_use_certificate\n");
ssl->cert->x509->ref++;
ssl->cert->x509->ref = 1;
return 1;
@ -307,3 +306,17 @@ int SSL_use_certificate_file(SSL *ssl, const char *file, int type)
{
return 0;
}
/*
* SSL_get_peer_certificate - get peer certification
*
* @param ssl - SSL point
*
* @return certification
*/
X509 *SSL_get_peer_certificate(const SSL *ssl)
{
SSL_ASSERT(ssl);
return ssl->session.peer;
}

View file

@ -74,7 +74,6 @@ int ssl_pm_new(SSL *ssl)
int mode;
int version;
SSL_CTX *ctx = ssl->ctx;
const SSL_METHOD *method = ssl->method;
struct x509_pm *x509_pm;
@ -185,9 +184,9 @@ int ssl_pm_handshake(SSL *ssl)
}
ssl_speed_up_exit();
if (!mbed_ret)
if (!mbed_ret) {
ret = 1;
else {
} else {
ret = 0;
SSL_DEBUG(1, "mbedtls_ssl_handshake [-0x%x]\n", -mbed_ret);
}