tls: Pass full Subject DN contents to "ready" callback
PATCH 1/2 tls: Pass full Subject DN contents to "ready" callback
Until now the ready callback would receive a displayable string as peer_identity (if peer was authenticated) which was either the Common Name or the Organization Name extracted from the subject DN in the peer's certificate.
In order to implement functionality similat to wpa_supplicant's substring_match= option for EAP-TLS, we need to look specifically at Common Name although if we have the full contents of the Subject DN that's even better as wpa_supplicant allows configurations to match against any element in the Subject DN, so if we do that iwd and wpa_s config files may be easier to convert in either direction.
We could also just pass the whole certificate struct to the callback but then we'd need to also have utilities for parsing the DN so instead we parse it in tls.c and convert it into the same string format that is used by wpa_s, openssl, etc. Parsing that string in user code is easier than parsing the original DER struct.
--- ell/asn1-private.h | 1 + ell/tls.c | 76 ++++++++++++++++++++++++++++++++-------------- 2 files changed, 55 insertions(+), 22 deletions(-)
ell/asn1-private.h +1 -0
@@ -30,6 +30,7 @@#define ASN1_ID_OID ASN1_ID(ASN1_CLASS_UNIVERSAL, 0, 0x06)#define ASN1_ID_UTF8STRING ASN1_ID(ASN1_CLASS_UNIVERSAL, 0, 0x0c)#define ASN1_ID_PRINTABLESTRING ASN1_ID(ASN1_CLASS_UNIVERSAL, 0, 0x13) +#define ASN1_ID_IA5STRING ASN1_ID(ASN1_CLASS_UNIVERSAL, 0, 0x16)struct asn1_oid {uint8_t asn1_len;
ell/tls.c +54 -22
122 lines not on this page · raw message
Signature · 1 line
2.20.1
PATCH 2/2 unit: Update expected peer identity strings in TLS
--- unit/test-tls.c | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-)
unit/test-tls.c +22 -11
@@ -326,7 +326,8 @@ static const struct tls_conn_test tls_conn_test_server_auth = { .server_key_path = CERTDIR "cert-server-key-pkcs8.pem", .server_expect_identity = NULL, .client_ca_cert_path = CERTDIR "cert-ca.pem", - .client_expect_identity = "Foo Example Organization", + .client_expect_identity = "/O=Foo Example Organization" + "/CN=Foo Example Organization/emailAddress=foo(a)mail.example", };static const struct tls_conn_test tls_conn_test_client_auth_attempt = {
@@ -341,7 +342,8 @@ static const struct tls_conn_test tls_conn_test_client_auth = { .server_cert_path = CERTDIR "cert-server.pem", .server_key_path = CERTDIR "cert-server-key-pkcs8.pem", .server_ca_cert_path = CERTDIR "cert-ca.pem", - .server_expect_identity = "Bar Example Organization", + .server_expect_identity ="/O=Bar Example Organization" + "/CN=Bar Example Organization/emailAddress=bar(a)mail.example", .client_cert_path = CERTDIR "cert-client.pem", .client_key_path = CERTDIR "cert-client-key-pkcs8.pem", .client_expect_identity = NULL,
@@ -353,29 +355,34 @@ static const struct tls_conn_test tls_conn_test_full_auth_attempt = { .server_ca_cert_path = CERTDIR "cert-ca.pem", .server_expect_identity = NULL, .client_ca_cert_path = CERTDIR "cert-ca.pem", - .client_expect_identity = "Foo Example Organization", + .client_expect_identity = "/O=Foo Example Organization" + "/CN=Foo Example Organization/emailAddress=foo(a)mail.example", };static const struct tls_conn_test tls_conn_test_full_auth = { .server_cert_path =CERTDIR "cert-server.pem" , .server_key_path =CERTDIR "cert-server-key-pkcs8.pem" , .server_ca_cert_path =CERTDIR "cert-ca.pem" , - .server_expect_identity ="Bar Example Organization" , + .server_expect_identity ="/O=Bar Example Organization" +"/CN=Bar Example Organization/emailAddress=bar(a)mail.example" , .client_cert_path =CERTDIR "cert-client.pem" , .client_key_path =CERTDIR "cert-client-key-pkcs8.pem" , .client_ca_cert_path =CERTDIR "cert-ca.pem" , - .client_expect_identity ="Foo Example Organization" , + .client_expect_identity ="/O=Foo Example Organization" +"/CN=Foo Example Organization/emailAddress=foo(a)mail.example" , };static const struct tls_conn_test tls_conn_test_bad_client_suite = { .server_cert_path =CERTDIR "cert-server.pem" , .server_key_path =CERTDIR "cert-server-key-pkcs8.pem" , .server_ca_cert_path =CERTDIR "cert-ca.pem" , - .server_expect_identity ="Bar Example Organization" , + .server_expect_identity ="/O=Bar Example Organization" +"/CN=Bar Example Organization/emailAddress=bar(a)mail.example" , .client_cert_path =CERTDIR "cert-client.pem" , .client_key_path =CERTDIR "cert-client-key-pkcs8.pem" , .client_ca_cert_path =CERTDIR "cert-ca.pem" , - .client_expect_identity ="Foo Example Organization" , + .client_expect_identity ="/O=Foo Example Organization" +"/CN=Foo Example Organization/emailAddress=foo(a)mail.example" , .client_cipher_suites = (const char *[]) {"UNKNOWN" ,NULL }, .expect_client_start_fail = true, };
@@ -384,13 +391,15 @@ static const struct tls_conn_test tls_conn_test_suite_mismatch = { .server_cert_path = CERTDIR "cert-server.pem", .server_key_path = CERTDIR "cert-server-key-pkcs8.pem", .server_ca_cert_path = CERTDIR "cert-ca.pem", - .server_expect_identity = "Bar Example Organization", + .server_expect_identity ="/O=Bar Example Organization" + "/CN=Bar Example Organization/emailAddress=bar(a)mail.example", .server_cipher_suites = (const char *[]) { "TLS_RSA_WITH_AES_128_CBC_SHA256", NULL }, .client_cert_path = CERTDIR "cert-client.pem", .client_key_path = CERTDIR "cert-client-key-pkcs8.pem", .client_ca_cert_path = CERTDIR "cert-ca.pem", - .client_expect_identity = "Foo Example Organization", + .client_expect_identity ="/O=Foo Example Organization" + "/CN=Foo Example Organization/emailAddress=foo(a)mail.example", .client_cipher_suites = (const char *[]) { "TLS_RSA_WITH_AES_256_CBC_SHA256", NULL }, .expect_alert = true,
@@ -401,11 +410,13 @@ static const struct tls_conn_test tls_conn_test_version_mismatch = { .server_cert_path = CERTDIR "cert-server.pem", .server_key_path = CERTDIR "cert-server-key-pkcs8.pem", .server_ca_cert_path = CERTDIR "cert-ca.pem", - .server_expect_identity = "Bar Example Organization", + .server_expect_identity ="/O=Bar Example Organization" + "/CN=Bar Example Organization/emailAddress=bar(a)mail.example", .client_cert_path = CERTDIR "cert-client.pem", .client_key_path = CERTDIR "cert-client-key-pkcs8.pem", .client_ca_cert_path = CERTDIR "cert-ca.pem", - .client_expect_identity = "Foo Example Organization", + .client_expect_identity ="/O=Foo Example Organization" + "/CN=Foo Example Organization/emailAddress=foo(a)mail.example", .expect_alert = true, .alert_desc = TLS_ALERT_PROTOCOL_VERSION, };
Signature · 1 line
2.20.1