From 2faa2376a0de66af42ff2c55e00106472090677a Mon Sep 17 00:00:00 2001 From: dongheng Date: Thu, 22 Sep 2016 15:39:28 +0800 Subject: [PATCH] components/openssl: add empty function to load verify file into SSL context 1. add empty function to load private key into SSL context 2. add empty function to load certification into SSL context 3. add function to load RSA private key --- components/openssl/include/openssl/ssl.h | 4 +-- components/openssl/library/ssl_pkey.c | 31 ++++++++++++++++++++++++ components/openssl/library/ssl_x509.c | 15 ++++++++++++ 3 files changed, 48 insertions(+), 2 deletions(-) diff --git a/components/openssl/include/openssl/ssl.h b/components/openssl/include/openssl/ssl.h index b7506c8fb0..865405d868 100644 --- a/components/openssl/include/openssl/ssl.h +++ b/components/openssl/include/openssl/ssl.h @@ -927,7 +927,7 @@ int SSL_CTX_use_PrivateKey_ASN1(int pk, SSL_CTX *ctx, const unsigned char *d, l * 1 : OK * 0 : failed */ -int SSL_CTX_use_PrivateKey_file(SSL_CTX *ctx, const char *file, int type);//adds the first private key found in file to ctx, The formatting type of the certificate must be specified from the known types SSL_FILETYPE_PEM, SSL_FILETYPE_ASN1. +int SSL_CTX_use_PrivateKey_file(SSL_CTX *ctx, const char *file, int type); /* * SSL_CTX_use_certificate - load the RSA private key into SSL context @@ -952,7 +952,7 @@ int SSL_CTX_use_RSAPrivateKey(SSL_CTX *ctx, RSA *rsa); * 1 : OK * 0 : failed */ -int SSL_CTX_use_RSAPrivateKey_ASN1(SSL_CTX *ctx, unsigned char *d, long len); +int SSL_CTX_use_RSAPrivateKey_ASN1(SSL_CTX *ctx, const unsigned char *d, long len); /* * SSL_CTX_use_certificate_file - load the RSA private key file into SSL context diff --git a/components/openssl/library/ssl_pkey.c b/components/openssl/library/ssl_pkey.c index c9866e27b5..1ab080ac28 100644 --- a/components/openssl/library/ssl_pkey.c +++ b/components/openssl/library/ssl_pkey.c @@ -165,3 +165,34 @@ failed1: return 0; } +/* + * SSL_CTX_use_certificate_file - load the private key file into SSL context + * + * @param ctx - SSL context point + * @param file - private key file name + * @param type - private key encoding type + * + * @return + * 1 : OK + * 0 : failed + */ +int SSL_CTX_use_PrivateKey_file(SSL_CTX *ctx, const char *file, int type) +{ + return 0; +} + +/* + * SSL_CTX_use_certificate_ASN1 - load the RSA ASN1 private key into SSL context + * + * @param ctx - SSL context point + * @param d - data point + * @param len - RSA private key length + * + * @return + * 1 : OK + * 0 : failed + */ +int SSL_CTX_use_RSAPrivateKey_ASN1(SSL_CTX *ctx, const unsigned char *d, long len) +{ + return SSL_CTX_use_PrivateKey_ASN1(0, ctx, d, len); +} diff --git a/components/openssl/library/ssl_x509.c b/components/openssl/library/ssl_x509.c index 102e5a543a..b0ddd42593 100644 --- a/components/openssl/library/ssl_x509.c +++ b/components/openssl/library/ssl_x509.c @@ -213,3 +213,18 @@ failed1: return 0; } +/* + * SSL_CTX_use_certificate_file - load the certification file into SSL context + * + * @param ctx - SSL context point + * @param file - certification file name + * @param type - certification encoding type + * + * @return + * 1 : OK + * 0 : failed + */ +int SSL_CTX_use_certificate_file(SSL_CTX *ctx, const char *file, int type) +{ + return 0; +}