|
@@ -130,20 +130,6 @@ const char * x509_name ( struct x509_certificate *cert ) {
|
130
|
130
|
return buf;
|
131
|
131
|
}
|
132
|
132
|
|
133
|
|
-/**
|
134
|
|
- * Free X.509 certificate
|
135
|
|
- *
|
136
|
|
- * @v refcnt Reference count
|
137
|
|
- */
|
138
|
|
-static void x509_free ( struct refcnt *refcnt ) {
|
139
|
|
- struct x509_certificate *cert =
|
140
|
|
- container_of ( refcnt, struct x509_certificate, refcnt );
|
141
|
|
-
|
142
|
|
- DBGC2 ( cert, "X509 %p freed\n", cert );
|
143
|
|
- free ( cert->extensions.auth_info.ocsp.uri );
|
144
|
|
- free ( cert );
|
145
|
|
-}
|
146
|
|
-
|
147
|
133
|
/**
|
148
|
134
|
* Discard a cached certificate
|
149
|
135
|
*
|
|
@@ -626,24 +612,19 @@ static int x509_parse_extended_key_usage ( struct x509_certificate *cert,
|
626
|
612
|
static int x509_parse_ocsp ( struct x509_certificate *cert,
|
627
|
613
|
const struct asn1_cursor *raw ) {
|
628
|
614
|
struct x509_ocsp_responder *ocsp = &cert->extensions.auth_info.ocsp;
|
629
|
|
- struct asn1_cursor cursor;
|
|
615
|
+ struct asn1_cursor *uri = &ocsp->uri;
|
630
|
616
|
int rc;
|
631
|
617
|
|
632
|
618
|
/* Enter accessLocation */
|
633
|
|
- memcpy ( &cursor, raw, sizeof ( cursor ) );
|
634
|
|
- if ( ( rc = asn1_enter ( &cursor, ASN1_IMPLICIT_TAG ( 6 ) ) ) != 0 ) {
|
|
619
|
+ memcpy ( uri, raw, sizeof ( *uri ) );
|
|
620
|
+ if ( ( rc = asn1_enter ( uri, ASN1_IMPLICIT_TAG ( 6 ) ) ) != 0 ) {
|
635
|
621
|
DBGC ( cert, "X509 %p OCSP does not contain "
|
636
|
622
|
"uniformResourceIdentifier:\n", cert );
|
637
|
623
|
DBGC_HDA ( cert, 0, raw->data, raw->len );
|
638
|
624
|
return rc;
|
639
|
625
|
}
|
640
|
|
-
|
641
|
|
- /* Record URI */
|
642
|
|
- ocsp->uri = zalloc ( cursor.len + 1 /* NUL */ );
|
643
|
|
- if ( ! ocsp->uri )
|
644
|
|
- return -ENOMEM;
|
645
|
|
- memcpy ( ocsp->uri, cursor.data, cursor.len );
|
646
|
|
- DBGC2 ( cert, "X509 %p OCSP URI is %s:\n", cert, ocsp->uri );
|
|
626
|
+ DBGC2 ( cert, "X509 %p OCSP URI is:\n", cert );
|
|
627
|
+ DBGC2_HDA ( cert, 0, uri->data, uri->len );
|
647
|
628
|
|
648
|
629
|
return 0;
|
649
|
630
|
}
|
|
@@ -1073,7 +1054,7 @@ int x509_certificate ( const void *data, size_t len,
|
1073
|
1054
|
*cert = zalloc ( sizeof ( **cert ) + cursor.len );
|
1074
|
1055
|
if ( ! *cert )
|
1075
|
1056
|
return -ENOMEM;
|
1076
|
|
- ref_init ( &(*cert)->refcnt, x509_free );
|
|
1057
|
+ ref_init ( &(*cert)->refcnt, NULL );
|
1077
|
1058
|
INIT_LIST_HEAD ( &(*cert)->list );
|
1078
|
1059
|
raw = ( *cert + 1 );
|
1079
|
1060
|
|
|
@@ -1363,7 +1344,7 @@ int x509_validate ( struct x509_certificate *cert,
|
1363
|
1344
|
}
|
1364
|
1345
|
|
1365
|
1346
|
/* Fail if OCSP is required */
|
1366
|
|
- if ( cert->extensions.auth_info.ocsp.uri &&
|
|
1347
|
+ if ( cert->extensions.auth_info.ocsp.uri.len &&
|
1367
|
1348
|
( ! cert->extensions.auth_info.ocsp.good ) ) {
|
1368
|
1349
|
DBGC ( cert, "X509 %p \"%s\" requires an OCSP check\n",
|
1369
|
1350
|
cert, x509_name ( cert ) );
|