From 1746e6f9ca913aada1db7fb91dc0f83885b50973 Mon Sep 17 00:00:00 2001 From: AnotherTest Date: Thu, 29 Oct 2020 11:55:41 +0330 Subject: [PATCH] LibTLS: Also read out the Organisational Unit from the certificate This needs to be read out if we want to actually verify the cert chain. --- Libraries/LibTLS/TLSv12.cpp | 4 ++++ Libraries/LibTLS/TLSv12.h | 1 + 2 files changed, 5 insertions(+) diff --git a/Libraries/LibTLS/TLSv12.cpp b/Libraries/LibTLS/TLSv12.cpp index 13bf311d6b..fd78dd74ad 100644 --- a/Libraries/LibTLS/TLSv12.cpp +++ b/Libraries/LibTLS/TLSv12.cpp @@ -339,6 +339,8 @@ static ssize_t _parse_asn1(const Context& context, Certificate& cert, const u8* cert.issuer_entity = String { (const char*)buffer + position, length }; } else if (_asn1_is_oid(oid, Constants::subject_oid)) { cert.issuer_subject = String { (const char*)buffer + position, length }; + } else if (_asn1_is_oid(oid, Constants::unit_oid)) { + cert.issuer_unit = String { (const char*)buffer + position, length }; } } else if (_asn1_is_field_present(fields, Constants::owner_id)) { if (_asn1_is_oid(oid, Constants::country_oid)) { @@ -351,6 +353,8 @@ static ssize_t _parse_asn1(const Context& context, Certificate& cert, const u8* cert.entity = String { (const char*)buffer + position, length }; } else if (_asn1_is_oid(oid, Constants::subject_oid)) { cert.subject = String { (const char*)buffer + position, length }; + } else if (_asn1_is_oid(oid, Constants::unit_oid)) { + cert.unit = String { (const char*)buffer + position, length }; } } break; diff --git a/Libraries/LibTLS/TLSv12.h b/Libraries/LibTLS/TLSv12.h index c263917c40..08abdc0832 100644 --- a/Libraries/LibTLS/TLSv12.h +++ b/Libraries/LibTLS/TLSv12.h @@ -463,6 +463,7 @@ constexpr static const u8 state_oid[] { 0x55, 0x04, 0x08, 0x00 }; constexpr static const u8 location_oid[] { 0x55, 0x04, 0x07, 0x00 }; constexpr static const u8 entity_oid[] { 0x55, 0x04, 0x0A, 0x00 }; constexpr static const u8 subject_oid[] { 0x55, 0x04, 0x03, 0x00 }; +constexpr static const u8 unit_oid[] { 0x55, 0x04, 0x0B, 0x00 }; constexpr static const u8 san_oid[] { 0x55, 0x1D, 0x11, 0x00 }; constexpr static const u8 ocsp_oid[] { 0x2B, 0x06, 0x01, 0x05, 0x05, 0x07, 0x30, 0x01, 0x00 };