Browse Source

[crypto] Allow for X.509 certificates with no common name

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 12 years ago
parent
commit
0ad8b601dd
3 changed files with 7 additions and 5 deletions
  1. 2
    1
      src/crypto/cms.c
  2. 3
    3
      src/crypto/x509.c
  3. 2
    1
      src/net/tls.c

+ 2
- 1
src/crypto/cms.c View File

@@ -745,7 +745,8 @@ int cms_verify ( struct cms_signature *sig, userptr_t data, size_t len,
745 745
 	/* Verify using all signerInfos */
746 746
 	list_for_each_entry ( info, &sig->info, list ) {
747 747
 		cert = x509_first ( info->chain );
748
-		if ( name && ( strcmp ( name, cert->subject.name ) != 0 ) )
748
+		if ( name && ( ( cert->subject.name == NULL ) ||
749
+			       ( strcmp ( cert->subject.name, name ) != 0 ) ) )
749 750
 			continue;
750 751
 		if ( ( rc = cms_verify_signer_info ( sig, info, data, len,
751 752
 						     time, root ) ) != 0 )

+ 3
- 3
src/crypto/x509.c View File

@@ -570,7 +570,7 @@ static int x509_parse_common_name ( struct x509_certificate *cert, char **name,
570 570
 			return rc;
571 571
 		}
572 572
 
573
-		/* Allocate name */
573
+		/* Allocate and copy name */
574 574
 		*name = zalloc ( name_cursor.len + 1 /* NUL */ );
575 575
 		if ( ! *name )
576 576
 			return -ENOMEM;
@@ -578,9 +578,9 @@ static int x509_parse_common_name ( struct x509_certificate *cert, char **name,
578 578
 		return 0;
579 579
 	}
580 580
 
581
+	/* Certificates may not have a commonName */
581 582
 	DBGC ( cert, "X509 %p no commonName found:\n", cert );
582
-	DBGC_HDA ( cert, 0, raw->data, raw->len );
583
-	return -ENOENT;
583
+	return 0;
584 584
 }
585 585
 
586 586
 /**

+ 2
- 1
src/net/tls.c View File

@@ -1399,7 +1399,8 @@ static int tls_new_certificate ( struct tls_session *tls,
1399 1399
 	assert ( cert != NULL );
1400 1400
 
1401 1401
 	/* Verify server name */
1402
-	if ( strcmp ( tls->name, cert->subject.name ) != 0 ) {
1402
+	if ( ( cert->subject.name == NULL ) ||
1403
+	     ( strcmp ( cert->subject.name, tls->name ) != 0 ) ) {
1403 1404
 		DBGC ( tls, "TLS %p server name incorrect (expected %s, got "
1404 1405
 		       "%s)\n", tls, tls->name, cert->subject.name );
1405 1406
 		return -EACCES_WRONG_NAME;

Loading…
Cancel
Save