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
 	/* Verify using all signerInfos */
745
 	/* Verify using all signerInfos */
746
 	list_for_each_entry ( info, &sig->info, list ) {
746
 	list_for_each_entry ( info, &sig->info, list ) {
747
 		cert = x509_first ( info->chain );
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
 			continue;
750
 			continue;
750
 		if ( ( rc = cms_verify_signer_info ( sig, info, data, len,
751
 		if ( ( rc = cms_verify_signer_info ( sig, info, data, len,
751
 						     time, root ) ) != 0 )
752
 						     time, root ) ) != 0 )

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

570
 			return rc;
570
 			return rc;
571
 		}
571
 		}
572
 
572
 
573
-		/* Allocate name */
573
+		/* Allocate and copy name */
574
 		*name = zalloc ( name_cursor.len + 1 /* NUL */ );
574
 		*name = zalloc ( name_cursor.len + 1 /* NUL */ );
575
 		if ( ! *name )
575
 		if ( ! *name )
576
 			return -ENOMEM;
576
 			return -ENOMEM;
578
 		return 0;
578
 		return 0;
579
 	}
579
 	}
580
 
580
 
581
+	/* Certificates may not have a commonName */
581
 	DBGC ( cert, "X509 %p no commonName found:\n", cert );
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
 	assert ( cert != NULL );
1399
 	assert ( cert != NULL );
1400
 
1400
 
1401
 	/* Verify server name */
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
 		DBGC ( tls, "TLS %p server name incorrect (expected %s, got "
1404
 		DBGC ( tls, "TLS %p server name incorrect (expected %s, got "
1404
 		       "%s)\n", tls, tls->name, cert->subject.name );
1405
 		       "%s)\n", tls, tls->name, cert->subject.name );
1405
 		return -EACCES_WRONG_NAME;
1406
 		return -EACCES_WRONG_NAME;

Loading…
Cancel
Save