summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfengweihao <[email protected]>2019-10-12 18:10:56 +0800
committerfengweihao <[email protected]>2019-10-12 18:10:56 +0800
commit8b089533e9c75bc6a99917cce71bc3839dd0ab44 (patch)
tree03eee4ad1ba695e279577660fbd7a3d904f0e7f0 /src
parentc1bddfac745e8b56cfda683bfec4e17724eb4937 (diff)
遗漏代码,证书为一层公钥读取问题
Diffstat (limited to 'src')
-rw-r--r--src/cert_session.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/cert_session.c b/src/cert_session.c
index 425d843..8626e41 100644
--- a/src/cert_session.c
+++ b/src/cert_session.c
@@ -281,9 +281,9 @@ finish:
X509* x509_get_root_ca(char *file, STACK_OF(X509) **stack_ca)
{
int x509_cnt = 0;
- X509 *x = NULL, *end = NULL;
BIO *bio = NULL;
- STACK_OF(X509) *stack_x509 = NULL;
+ STACK_OF(X509) *stack_x509 = NULL;
+ X509 *x = NULL, *node = NULL, *root = NULL;
if(!file){
mesa_runtime_log(RLOG_LV_FATAL, MODULE_NAME, "Input cert file is empty.");
@@ -307,12 +307,12 @@ X509* x509_get_root_ca(char *file, STACK_OF(X509) **stack_ca)
while(NULL!=(x=PEM_read_bio_X509_AUX(bio, NULL, NULL, NULL))){
if (0 == X509_NAME_cmp(X509_get_issuer_name(x), X509_get_subject_name(x))){
/*This is root ca**/
+ root = x;
continue;
- X509_free(x);
};
/*This is last ca*/
if (x509_get_last_ca(file, x) == 0){
- end = x;
+ node = x;
continue;
}
sk_X509_push(stack_x509, x);
@@ -320,10 +320,13 @@ X509* x509_get_root_ca(char *file, STACK_OF(X509) **stack_ca)
}
if (x509_cnt >= 1)
*stack_ca = stack_x509;
-
+ if (node != NULL)
+ X509_free(root);
+ else
+ node = root;
BIO_free (bio);
finish:
- return end;
+ return node;
}
static X509 *