diff mbox series

Fix build failure by loading CMS certificate

Message ID 20180817085425.9097-1-sbabic@denx.de
State Accepted
Headers show
Series Fix build failure by loading CMS certificate | expand

Commit Message

Stefano Babic Aug. 17, 2018, 8:54 a.m. UTC
The correct way to access certificate names is using accessors
provided by openSSL library instead of direct access to fields
inside X509 structure. Changes in openSSL cause build error
because "name" is not anymore part of X509 struct.

Fix it using accessor to get issuer and subject of a
certificate.

Signed-off-by: Stefano Babic <sbabic@denx.de>
---
 corelib/verify_signature.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/corelib/verify_signature.c b/corelib/verify_signature.c
index a3192f5..664f680 100644
--- a/corelib/verify_signature.c
+++ b/corelib/verify_signature.c
@@ -243,7 +243,11 @@  static X509_STORE *load_cert_chain(const char *file)
 		crt = PEM_read_bio_X509(castore_bio, NULL, 0, NULL);
 		if (crt) {
 			crt_count++;
-			TRACE("Read PEM #%d: %s", crt_count, crt->name);
+			char *subj = X509_NAME_oneline(X509_get_subject_name(crt), NULL, 0);
+			char *issuer = X509_NAME_oneline(X509_get_issuer_name(crt), NULL, 0);
+			TRACE("Read PEM #%d: %s %s", crt_count, issuer, subj);
+			free(subj);
+			free(issuer);
 			if (X509_STORE_add_cert(castore, crt) == 0) {
 				TRACE("Adding certificate to X509_STORE failed");
 				BIO_free(castore_bio);