components/openssl: add SSL and SSL context verify mode selection

This commit is contained in:
dongheng
2016-09-23 11:41:57 +08:00
parent f5d9bfc7ae
commit e475d0539e
9 changed files with 88 additions and 95 deletions
+35 -15
View File
@@ -284,6 +284,7 @@ SSL *SSL_new(SSL_CTX *ctx)
ssl->cert = ctx->cert;
ssl->client_CA = ctx->client_CA;
ssl->verify_mode = ctx->verify_mode;
ret = SSL_METHOD_CALL(new, ssl);
if (ret)
@@ -1726,21 +1727,6 @@ long SSL_set_timeout(SSL *ssl, long t)
return t;
}
/*
* SSL_set_verify - set the SSL verifying of the SSL context
*
* @param ctx - SSL point
* @param mode - verifying mode
* @param verify_callback - verifying callback function
*
* @return none
*/
void SSL_set_verify(SSL *ssl, int mode, int (*verify_callback)(int, X509_STORE_CTX *))
{
SSL_ASSERT(ssl);
SSL_ASSERT(verify_callback);
}
/*
* SSL_get_verify_result - get the verifying result of the SSL certification
*
@@ -1812,3 +1798,37 @@ void SSL_set_verify_depth(SSL *ssl, int depth)
ssl->param.depth = depth;
}
/*
* SSL_CTX_set_verify - set the SSL context verifying of the SSL context
*
* @param ctx - SSL context point
* @param mode - verifying mode
* @param verify_callback - verifying callback function
*
* @return none
*/
void SSL_CTX_set_verify(SSL_CTX *ctx, int mode, int (*verify_callback)(int, X509_STORE_CTX *))
{
SSL_ASSERT(ctx);
ctx->verify_mode = mode;
ctx->default_verify_callback = verify_callback;
}
/*
* SSL_set_verify - set the SSL verifying of the SSL context
*
* @param ctx - SSL point
* @param mode - verifying mode
* @param verify_callback - verifying callback function
*
* @return none
*/
void SSL_set_verify(SSL *ssl, int mode, int (*verify_callback)(int, X509_STORE_CTX *))
{
SSL_ASSERT(ctx);
ssl->verify_mode = mode;
ssl->verify_callback = verify_callback;
}
-1
View File
@@ -26,7 +26,6 @@ IMPLEMENT_TLS_METHOD_FUNC(TLS_method_func,
ssl_pm_set_fd, ssl_pm_get_fd,
ssl_pm_set_bufflen,
ssl_pm_get_verify_result,
ssl_pm_reload_crt,
ssl_pm_get_state);
/*
+1 -7
View File
@@ -160,13 +160,7 @@ int SSL_use_PrivateKey(SSL *ssl, EVP_PKEY *pkey)
ssl->cert->pkey = pkey;
ssl_ret = SSL_METHOD_CALL(reload_crt, ssl);
if (ssl_ret)
ret = 0;
else
ret = 1;
return ret;
return 1;
}
/*
+1 -10
View File
@@ -138,9 +138,6 @@ int SSL_CTX_add_client_CA(SSL_CTX *ctx, X509 *x)
*/
int SSL_add_client_CA(SSL *ssl, X509 *x)
{
int ret;
int ssl_ret;
SSL_ASSERT(ssl);
SSL_ASSERT(x);
@@ -151,13 +148,7 @@ int SSL_add_client_CA(SSL *ssl, X509 *x)
ssl->client_CA = x;
ssl_ret = SSL_METHOD_CALL(reload_crt, ssl);
if (ssl_ret)
ret = 0;
else
ret = 1;
return ret;
return 1;
}
/*