From 99c798d87a94838be62976cb1632e7d0a9550df3 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Tue, 8 May 2012 10:57:50 +0100 Subject: [crypto] Add x509_append_raw() Signed-off-by: Michael Brown --- src/net/tls.c | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) (limited to 'src/net') diff --git a/src/net/tls.c b/src/net/tls.c index 3a8a0e05b..6cb63be5b 100644 --- a/src/net/tls.c +++ b/src/net/tls.c @@ -1312,37 +1312,24 @@ static int tls_parse_chain ( struct tls_session *tls, goto err_overlength; } - /* Parse certificate */ - if ( ( rc = x509_certificate ( certificate->data, - certificate_len, - &cert ) ) != 0 ) { - DBGC ( tls, "TLS %p could not parse certificate: %s\n", + /* Add certificate to chain */ + if ( ( rc = x509_append_raw ( tls->chain, certificate->data, + certificate_len ) ) != 0 ) { + DBGC ( tls, "TLS %p could not append certificate: %s\n", tls, strerror ( rc ) ); DBGC_HDA ( tls, 0, data, ( end - data ) ); goto err_parse; } + cert = x509_last ( tls->chain ); DBGC ( tls, "TLS %p found certificate %s\n", tls, cert->subject.name ); - /* Append certificate to chain */ - if ( ( rc = x509_append ( tls->chain, cert ) ) != 0 ) { - DBGC ( tls, "TLS %p could not append certificate: %s\n", - tls, strerror ( rc ) ); - goto err_append; - } - - /* Drop reference to certificate */ - x509_put ( cert ); - cert = NULL; - /* Move to next certificate in list */ data = next; } return 0; - err_append: - x509_put ( cert ); err_parse: err_overlength: x509_chain_put ( tls->chain ); -- cgit v1.2.3-55-g7522