|
@@ -177,11 +177,11 @@ static int ocsp_request ( struct ocsp_check *ocsp ) {
|
177
|
177
|
asn1_wrap ( builder, ASN1_SEQUENCE ),
|
178
|
178
|
asn1_wrap ( builder, ASN1_SEQUENCE ) ) ) != 0 ) {
|
179
|
179
|
DBGC ( ocsp, "OCSP %p \"%s\" could not build request: %s\n",
|
180
|
|
- ocsp, ocsp->cert->subject.name, strerror ( rc ) );
|
|
180
|
+ ocsp, x509_name ( ocsp->cert ), strerror ( rc ) );
|
181
|
181
|
return rc;
|
182
|
182
|
}
|
183
|
183
|
DBGC2 ( ocsp, "OCSP %p \"%s\" request is:\n",
|
184
|
|
- ocsp, ocsp->cert->subject.name );
|
|
184
|
+ ocsp, x509_name ( ocsp->cert ) );
|
185
|
185
|
DBGC2_HDA ( ocsp, 0, builder->data, builder->len );
|
186
|
186
|
|
187
|
187
|
/* Parse certificate ID for comparison with response */
|
|
@@ -192,7 +192,7 @@ static int ocsp_request ( struct ocsp_check *ocsp ) {
|
192
|
192
|
asn1_enter ( cert_id, ASN1_SEQUENCE ),
|
193
|
193
|
asn1_enter ( cert_id, ASN1_SEQUENCE ) ) ) != 0 ) {
|
194
|
194
|
DBGC ( ocsp, "OCSP %p \"%s\" could not locate certID: %s\n",
|
195
|
|
- ocsp, ocsp->cert->subject.name, strerror ( rc ) );
|
|
195
|
+ ocsp, x509_name ( ocsp->cert ), strerror ( rc ) );
|
196
|
196
|
return rc;
|
197
|
197
|
}
|
198
|
198
|
|
|
@@ -218,7 +218,7 @@ static int ocsp_uri_string ( struct ocsp_check *ocsp ) {
|
218
|
218
|
base_uri_string = ocsp->cert->extensions.auth_info.ocsp.uri;
|
219
|
219
|
if ( ! base_uri_string ) {
|
220
|
220
|
DBGC ( ocsp, "OCSP %p \"%s\" has no OCSP URI\n",
|
221
|
|
- ocsp, ocsp->cert->subject.name );
|
|
221
|
+ ocsp, x509_name ( ocsp->cert ) );
|
222
|
222
|
rc = -ENOTTY;
|
223
|
223
|
goto err_no_uri;
|
224
|
224
|
}
|
|
@@ -250,7 +250,7 @@ static int ocsp_uri_string ( struct ocsp_check *ocsp ) {
|
250
|
250
|
goto err_ocsp_uri;
|
251
|
251
|
}
|
252
|
252
|
DBGC2 ( ocsp, "OCSP %p \"%s\" URI is %s\n",
|
253
|
|
- ocsp, ocsp->cert->subject.name, ocsp->uri_string );
|
|
253
|
+ ocsp, x509_name ( ocsp->cert ), ocsp->uri_string );
|
254
|
254
|
|
255
|
255
|
/* Success */
|
256
|
256
|
rc = 0;
|
|
@@ -327,14 +327,14 @@ static int ocsp_parse_response_status ( struct ocsp_check *ocsp,
|
327
|
327
|
memcpy ( &cursor, raw, sizeof ( cursor ) );
|
328
|
328
|
if ( ( rc = asn1_enter ( &cursor, ASN1_ENUMERATED ) ) != 0 ) {
|
329
|
329
|
DBGC ( ocsp, "OCSP %p \"%s\" could not locate responseStatus: "
|
330
|
|
- "%s\n", ocsp, ocsp->cert->subject.name, strerror ( rc ));
|
|
330
|
+ "%s\n", ocsp, x509_name ( ocsp->cert ), strerror ( rc ));
|
331
|
331
|
return rc;
|
332
|
332
|
}
|
333
|
333
|
|
334
|
334
|
/* Extract response status */
|
335
|
335
|
if ( cursor.len != sizeof ( status ) ) {
|
336
|
336
|
DBGC ( ocsp, "OCSP %p \"%s\" invalid status:\n",
|
337
|
|
- ocsp, ocsp->cert->subject.name );
|
|
337
|
+ ocsp, x509_name ( ocsp->cert ) );
|
338
|
338
|
DBGC_HDA ( ocsp, 0, cursor.data, cursor.len );
|
339
|
339
|
return -EINVAL;
|
340
|
340
|
}
|
|
@@ -343,7 +343,7 @@ static int ocsp_parse_response_status ( struct ocsp_check *ocsp,
|
343
|
343
|
/* Check response status */
|
344
|
344
|
if ( status != OCSP_STATUS_SUCCESSFUL ) {
|
345
|
345
|
DBGC ( ocsp, "OCSP %p \"%s\" response status %d\n",
|
346
|
|
- ocsp, ocsp->cert->subject.name, status );
|
|
346
|
+ ocsp, x509_name ( ocsp->cert ), status );
|
347
|
347
|
return EPROTO_STATUS ( status );
|
348
|
348
|
}
|
349
|
349
|
|
|
@@ -368,7 +368,7 @@ static int ocsp_parse_response_type ( struct ocsp_check *ocsp,
|
368
|
368
|
/* Check responseType is "basic" */
|
369
|
369
|
if ( asn1_compare ( &oid_basic_response_type_cursor, &cursor ) != 0 ) {
|
370
|
370
|
DBGC ( ocsp, "OCSP %p \"%s\" response type not supported:\n",
|
371
|
|
- ocsp, ocsp->cert->subject.name );
|
|
371
|
+ ocsp, x509_name ( ocsp->cert ) );
|
372
|
372
|
DBGC_HDA ( ocsp, 0, cursor.data, cursor.len );
|
373
|
373
|
return -ENOTSUP_RESPONSE_TYPE;
|
374
|
374
|
}
|
|
@@ -443,17 +443,17 @@ static int ocsp_parse_responder_id ( struct ocsp_check *ocsp,
|
443
|
443
|
switch ( type ) {
|
444
|
444
|
case ASN1_EXPLICIT_TAG ( 1 ) :
|
445
|
445
|
DBGC2 ( ocsp, "OCSP %p \"%s\" responder identified by name\n",
|
446
|
|
- ocsp, ocsp->cert->subject.name );
|
|
446
|
+ ocsp, x509_name ( ocsp->cert ) );
|
447
|
447
|
responder->compare = ocsp_compare_responder_name;
|
448
|
448
|
return 0;
|
449
|
449
|
case ASN1_EXPLICIT_TAG ( 2 ) :
|
450
|
450
|
DBGC2 ( ocsp, "OCSP %p \"%s\" responder identified by key "
|
451
|
|
- "hash\n", ocsp, ocsp->cert->subject.name );
|
|
451
|
+ "hash\n", ocsp, x509_name ( ocsp->cert ) );
|
452
|
452
|
responder->compare = ocsp_compare_responder_key_hash;
|
453
|
453
|
return 0;
|
454
|
454
|
default:
|
455
|
455
|
DBGC ( ocsp, "OCSP %p \"%s\" unsupported responder ID type "
|
456
|
|
- "%d\n", ocsp, ocsp->cert->subject.name, type );
|
|
456
|
+ "%d\n", ocsp, x509_name ( ocsp->cert ), type );
|
457
|
457
|
return -ENOTSUP_RESPONDER_ID;
|
458
|
458
|
}
|
459
|
459
|
}
|
|
@@ -474,7 +474,7 @@ static int ocsp_parse_cert_id ( struct ocsp_check *ocsp,
|
474
|
474
|
asn1_shrink_any ( &cursor );
|
475
|
475
|
if ( asn1_compare ( &cursor, &ocsp->request.cert_id ) != 0 ) {
|
476
|
476
|
DBGC ( ocsp, "OCSP %p \"%s\" certID mismatch:\n",
|
477
|
|
- ocsp, ocsp->cert->subject.name );
|
|
477
|
+ ocsp, x509_name ( ocsp->cert ) );
|
478
|
478
|
DBGC_HDA ( ocsp, 0, ocsp->request.cert_id.data,
|
479
|
479
|
ocsp->request.cert_id.len );
|
480
|
480
|
DBGC_HDA ( ocsp, 0, cursor.data, cursor.len );
|
|
@@ -512,7 +512,7 @@ static int ocsp_parse_responses ( struct ocsp_check *ocsp,
|
512
|
512
|
/* Check certStatus */
|
513
|
513
|
if ( asn1_type ( &cursor ) != ASN1_IMPLICIT_TAG ( 0 ) ) {
|
514
|
514
|
DBGC ( ocsp, "OCSP %p \"%s\" non-good certStatus:\n",
|
515
|
|
- ocsp, ocsp->cert->subject.name );
|
|
515
|
+ ocsp, x509_name ( ocsp->cert ) );
|
516
|
516
|
DBGC_HDA ( ocsp, 0, cursor.data, cursor.len );
|
517
|
517
|
return -EACCES_CERT_STATUS;
|
518
|
518
|
}
|
|
@@ -522,11 +522,11 @@ static int ocsp_parse_responses ( struct ocsp_check *ocsp,
|
522
|
522
|
if ( ( rc = asn1_generalized_time ( &cursor,
|
523
|
523
|
&response->this_update ) ) != 0 ) {
|
524
|
524
|
DBGC ( ocsp, "OCSP %p \"%s\" could not parse thisUpdate: %s\n",
|
525
|
|
- ocsp, ocsp->cert->subject.name, strerror ( rc ) );
|
|
525
|
+ ocsp, x509_name ( ocsp->cert ), strerror ( rc ) );
|
526
|
526
|
return rc;
|
527
|
527
|
}
|
528
|
528
|
DBGC2 ( ocsp, "OCSP %p \"%s\" this update was at time %lld\n",
|
529
|
|
- ocsp, ocsp->cert->subject.name, response->this_update );
|
|
529
|
+ ocsp, x509_name ( ocsp->cert ), response->this_update );
|
530
|
530
|
asn1_skip_any ( &cursor );
|
531
|
531
|
|
532
|
532
|
/* Parse nextUpdate, if present */
|
|
@@ -536,11 +536,11 @@ static int ocsp_parse_responses ( struct ocsp_check *ocsp,
|
536
|
536
|
&response->next_update ) ) != 0 ) {
|
537
|
537
|
DBGC ( ocsp, "OCSP %p \"%s\" could not parse "
|
538
|
538
|
"nextUpdate: %s\n", ocsp,
|
539
|
|
- ocsp->cert->subject.name, strerror ( rc ) );
|
|
539
|
+ x509_name ( ocsp->cert ), strerror ( rc ) );
|
540
|
540
|
return rc;
|
541
|
541
|
}
|
542
|
542
|
DBGC2 ( ocsp, "OCSP %p \"%s\" next update is at time %lld\n",
|
543
|
|
- ocsp, ocsp->cert->subject.name, response->next_update );
|
|
543
|
+ ocsp, x509_name ( ocsp->cert ), response->next_update );
|
544
|
544
|
} else {
|
545
|
545
|
/* If no nextUpdate is present, this indicates that
|
546
|
546
|
* "newer revocation information is available all the
|
|
@@ -550,7 +550,7 @@ static int ocsp_parse_responses ( struct ocsp_check *ocsp,
|
550
|
550
|
* time and it would still be valid.
|
551
|
551
|
*/
|
552
|
552
|
DBGC ( ocsp, "OCSP %p \"%s\" responder is a moron\n",
|
553
|
|
- ocsp, ocsp->cert->subject.name );
|
|
553
|
+ ocsp, x509_name ( ocsp->cert ) );
|
554
|
554
|
response->next_update = time ( NULL );
|
555
|
555
|
}
|
556
|
556
|
|
|
@@ -630,7 +630,7 @@ static int ocsp_parse_certs ( struct ocsp_check *ocsp,
|
630
|
630
|
&cert ) ) != 0 ) {
|
631
|
631
|
DBGC ( ocsp, "OCSP %p \"%s\" could not parse "
|
632
|
632
|
"certificate: %s\n", ocsp,
|
633
|
|
- ocsp->cert->subject.name, strerror ( rc ) );
|
|
633
|
+ x509_name ( ocsp->cert ), strerror ( rc ) );
|
634
|
634
|
DBGC_HDA ( ocsp, 0, cursor.data, cursor.len );
|
635
|
635
|
return rc;
|
636
|
636
|
}
|
|
@@ -638,9 +638,10 @@ static int ocsp_parse_certs ( struct ocsp_check *ocsp,
|
638
|
638
|
/* Use if this certificate matches the responder ID */
|
639
|
639
|
if ( response->responder.compare ( ocsp, cert ) == 0 ) {
|
640
|
640
|
response->signer = cert;
|
641
|
|
- DBGC2 ( ocsp, "OCSP %p \"%s\" response is signed by "
|
642
|
|
- "\"%s\"\n", ocsp, ocsp->cert->subject.name,
|
643
|
|
- response->signer->subject.name );
|
|
641
|
+ DBGC2 ( ocsp, "OCSP %p \"%s\" response is signed by ",
|
|
642
|
+ ocsp, x509_name ( ocsp->cert ) );
|
|
643
|
+ DBGC2 ( ocsp, "\"%s\"\n",
|
|
644
|
+ x509_name ( response->signer ) );
|
644
|
645
|
return 0;
|
645
|
646
|
}
|
646
|
647
|
|
|
@@ -650,7 +651,7 @@ static int ocsp_parse_certs ( struct ocsp_check *ocsp,
|
650
|
651
|
}
|
651
|
652
|
|
652
|
653
|
DBGC ( ocsp, "OCSP %p \"%s\" missing responder certificate\n",
|
653
|
|
- ocsp, ocsp->cert->subject.name );
|
|
654
|
+ ocsp, x509_name ( ocsp->cert ) );
|
654
|
655
|
return -EACCES_NO_RESPONDER;
|
655
|
656
|
}
|
656
|
657
|
|
|
@@ -682,17 +683,17 @@ static int ocsp_parse_basic_response ( struct ocsp_check *ocsp,
|
682
|
683
|
if ( ( rc = asn1_signature_algorithm ( &cursor, algorithm ) ) != 0 ) {
|
683
|
684
|
DBGC ( ocsp, "OCSP %p \"%s\" cannot parse signature "
|
684
|
685
|
"algorithm: %s\n",
|
685
|
|
- ocsp, ocsp->cert->subject.name, strerror ( rc ) );
|
|
686
|
+ ocsp, x509_name ( ocsp->cert ), strerror ( rc ) );
|
686
|
687
|
return rc;
|
687
|
688
|
}
|
688
|
689
|
DBGC2 ( ocsp, "OCSP %p \"%s\" signature algorithm is %s\n",
|
689
|
|
- ocsp, ocsp->cert->subject.name, (*algorithm)->name );
|
|
690
|
+ ocsp, x509_name ( ocsp->cert ), (*algorithm)->name );
|
690
|
691
|
asn1_skip_any ( &cursor );
|
691
|
692
|
|
692
|
693
|
/* Parse signature */
|
693
|
694
|
if ( ( rc = asn1_integral_bit_string ( &cursor, signature ) ) != 0 ) {
|
694
|
695
|
DBGC ( ocsp, "OCSP %p \"%s\" cannot parse signature: %s\n",
|
695
|
|
- ocsp, ocsp->cert->subject.name, strerror ( rc ) );
|
|
696
|
+ ocsp, x509_name ( ocsp->cert ), strerror ( rc ) );
|
696
|
697
|
return rc;
|
697
|
698
|
}
|
698
|
699
|
asn1_skip_any ( &cursor );
|
|
@@ -836,7 +837,7 @@ static int ocsp_check_signature ( struct ocsp_check *ocsp,
|
836
|
837
|
if ( ( rc = pubkey_init ( pubkey, pubkey_ctx, public_key->raw.data,
|
837
|
838
|
public_key->raw.len ) ) != 0 ) {
|
838
|
839
|
DBGC ( ocsp, "OCSP %p \"%s\" could not initialise public key: "
|
839
|
|
- "%s\n", ocsp, ocsp->cert->subject.name, strerror ( rc ));
|
|
840
|
+ "%s\n", ocsp, x509_name ( ocsp->cert ), strerror ( rc ));
|
840
|
841
|
goto err_init;
|
841
|
842
|
}
|
842
|
843
|
|
|
@@ -845,12 +846,12 @@ static int ocsp_check_signature ( struct ocsp_check *ocsp,
|
845
|
846
|
response->signature.data,
|
846
|
847
|
response->signature.len ) ) != 0 ) {
|
847
|
848
|
DBGC ( ocsp, "OCSP %p \"%s\" signature verification failed: "
|
848
|
|
- "%s\n", ocsp, ocsp->cert->subject.name, strerror ( rc ));
|
|
849
|
+ "%s\n", ocsp, x509_name ( ocsp->cert ), strerror ( rc ));
|
849
|
850
|
goto err_verify;
|
850
|
851
|
}
|
851
|
852
|
|
852
|
853
|
DBGC2 ( ocsp, "OCSP %p \"%s\" signature is correct\n",
|
853
|
|
- ocsp, ocsp->cert->subject.name );
|
|
854
|
+ ocsp, x509_name ( ocsp->cert ) );
|
854
|
855
|
|
855
|
856
|
err_verify:
|
856
|
857
|
pubkey_final ( pubkey, pubkey_ctx );
|
|
@@ -892,10 +893,10 @@ int ocsp_validate ( struct ocsp_check *ocsp, time_t time ) {
|
892
|
893
|
x509_invalidate ( signer );
|
893
|
894
|
if ( ( rc = x509_validate ( signer, ocsp->issuer, time,
|
894
|
895
|
&ocsp_root ) ) != 0 ) {
|
895
|
|
- DBGC ( ocsp, "OCSP %p \"%s\" could not validate "
|
896
|
|
- "signer \"%s\": %s\n", ocsp,
|
897
|
|
- ocsp->cert->subject.name, signer->subject.name,
|
898
|
|
- strerror ( rc ) );
|
|
896
|
+ DBGC ( ocsp, "OCSP %p \"%s\" could not validate ",
|
|
897
|
+ ocsp, x509_name ( ocsp->cert ) );
|
|
898
|
+ DBGC ( ocsp, "signer \"%s\": %s\n",
|
|
899
|
+ x509_name ( signer ), strerror ( rc ) );
|
899
|
900
|
return rc;
|
900
|
901
|
}
|
901
|
902
|
|
|
@@ -904,9 +905,10 @@ int ocsp_validate ( struct ocsp_check *ocsp, time_t time ) {
|
904
|
905
|
*/
|
905
|
906
|
if ( ! ( signer->extensions.ext_usage.bits &
|
906
|
907
|
X509_OCSP_SIGNING ) ) {
|
907
|
|
- DBGC ( ocsp, "OCSP %p \"%s\" signer \"%s\" is "
|
908
|
|
- "not an OCSP-signing certificate\n", ocsp,
|
909
|
|
- ocsp->cert->subject.name, signer->subject.name );
|
|
908
|
+ DBGC ( ocsp, "OCSP %p \"%s\" ",
|
|
909
|
+ ocsp, x509_name ( ocsp->cert ) );
|
|
910
|
+ DBGC ( ocsp, "signer \"%s\" is not an OCSP-signing "
|
|
911
|
+ "certificate\n", x509_name ( signer ) );
|
910
|
912
|
return -EACCES_NON_OCSP_SIGNING;
|
911
|
913
|
}
|
912
|
914
|
}
|
|
@@ -920,16 +922,16 @@ int ocsp_validate ( struct ocsp_check *ocsp, time_t time ) {
|
920
|
922
|
*/
|
921
|
923
|
if ( response->this_update > ( time + X509_ERROR_MARGIN_TIME ) ) {
|
922
|
924
|
DBGC ( ocsp, "OCSP %p \"%s\" response is not yet valid (at "
|
923
|
|
- "time %lld)\n", ocsp, ocsp->cert->subject.name, time );
|
|
925
|
+ "time %lld)\n", ocsp, x509_name ( ocsp->cert ), time );
|
924
|
926
|
return -EACCES_STALE;
|
925
|
927
|
}
|
926
|
928
|
if ( response->next_update < ( time - X509_ERROR_MARGIN_TIME ) ) {
|
927
|
929
|
DBGC ( ocsp, "OCSP %p \"%s\" response is stale (at time "
|
928
|
|
- "%lld)\n", ocsp, ocsp->cert->subject.name, time );
|
|
930
|
+ "%lld)\n", ocsp, x509_name ( ocsp->cert ), time );
|
929
|
931
|
return -EACCES_STALE;
|
930
|
932
|
}
|
931
|
933
|
DBGC2 ( ocsp, "OCSP %p \"%s\" response is valid (at time %lld)\n",
|
932
|
|
- ocsp, ocsp->cert->subject.name, time );
|
|
934
|
+ ocsp, x509_name ( ocsp->cert ), time );
|
933
|
935
|
|
934
|
936
|
/* Mark certificate as passing OCSP verification */
|
935
|
937
|
ocsp->cert->extensions.auth_info.ocsp.good = 1;
|
|
@@ -938,11 +940,12 @@ int ocsp_validate ( struct ocsp_check *ocsp, time_t time ) {
|
938
|
940
|
if ( ( rc = x509_validate ( ocsp->cert, ocsp->issuer, time,
|
939
|
941
|
&ocsp_root ) ) != 0 ) {
|
940
|
942
|
DBGC ( ocsp, "OCSP %p \"%s\" could not validate certificate: "
|
941
|
|
- "%s\n", ocsp, ocsp->cert->subject.name, strerror ( rc ));
|
|
943
|
+ "%s\n", ocsp, x509_name ( ocsp->cert ), strerror ( rc ));
|
942
|
944
|
return rc;
|
943
|
945
|
}
|
944
|
|
- DBGC ( ocsp, "OCSP %p \"%s\" successfully validated using \"%s\"\n",
|
945
|
|
- ocsp, ocsp->cert->subject.name, signer->subject.name );
|
|
946
|
+ DBGC ( ocsp, "OCSP %p \"%s\" successfully validated ",
|
|
947
|
+ ocsp, x509_name ( ocsp->cert ) );
|
|
948
|
+ DBGC ( ocsp, "using \"%s\"\n", x509_name ( signer ) );
|
946
|
949
|
|
947
|
950
|
return 0;
|
948
|
951
|
}
|