@@ -1085,69 +1085,6 @@ def test_ct_submission():
10851085 if total_count < 2 :
10861086 raise (Exception ("Got %d total submissions, expected at least 2" % total_count ))
10871087
1088- def check_ocsp_basic_oid (cert_file , issuer_file , url ):
1089- """
1090- This function checks if an OCSP response was successful, but doesn't verify
1091- the signature or timestamp. This is useful when simulating the past, so we
1092- don't incorrectly reject a response for being in the past.
1093- """
1094- ocsp_request = make_ocsp_req (cert_file , issuer_file )
1095- responses = fetch_ocsp (ocsp_request , url )
1096- # An unauthorized response (for instance, if the OCSP responder doesn't know
1097- # about this cert) will just be 30 03 0A 01 06. A "good" or "revoked"
1098- # response will contain, among other things, the id-pkix-ocsp-basic OID
1099- # identifying the response type. We look for that OID to confirm we got a
1100- # successful response.
1101- expected = bytearray .fromhex ("06 09 2B 06 01 05 05 07 30 01 01" )
1102- for resp in responses :
1103- if not expected in bytearray (resp ):
1104- raise (Exception ("Did not receive successful OCSP response: %s doesn't contain %s" %
1105- (base64 .b64encode (resp ), base64 .b64encode (expected ))))
1106-
1107- ocsp_exp_unauth_setup_data = {}
1108- @register_six_months_ago
1109- def ocsp_exp_unauth_setup ():
1110- client = chisel2 .make_client (None )
1111- cert_file = temppath ('ocsp_exp_unauth_setup.pem' )
1112- chisel2 .auth_and_issue ([random_domain ()], client = client , cert_output = cert_file .name )
1113-
1114- # Since our servers are pretending to be in the past, but the openssl cli
1115- # isn't, we'll get an expired OCSP response. Just check that it exists;
1116- # don't do the full verification (which would fail).
1117- lastException = None
1118- for issuer_file in glob .glob ("test/certs/webpki/int-rsa-*.cert.pem" ):
1119- try :
1120- check_ocsp_basic_oid (cert_file .name , issuer_file , "http://localhost:4002" )
1121- global ocsp_exp_unauth_setup_data
1122- ocsp_exp_unauth_setup_data ['cert_file' ] = cert_file .name
1123- return
1124- except Exception as e :
1125- lastException = e
1126- continue
1127- raise (lastException )
1128-
1129- def test_ocsp_exp_unauth ():
1130- tries = 0
1131- if 'cert_file' not in ocsp_exp_unauth_setup_data :
1132- raise Exception ("ocsp_exp_unauth_setup didn't run" )
1133- cert_file = ocsp_exp_unauth_setup_data ['cert_file' ]
1134- last_error = ""
1135- while tries < 5 :
1136- try :
1137- verify_ocsp (cert_file , "test/certs/webpki/int-rsa-*.cert.pem" , "http://localhost:4002" , "XXX" )
1138- raise (Exception ("Unexpected return from verify_ocsp" ))
1139- except subprocess .CalledProcessError as cpe :
1140- last_error = cpe .output
1141- if cpe .output == b"Responder Error: unauthorized (6)\n " :
1142- break
1143- except e :
1144- last_error = e
1145- pass
1146- tries += 1
1147- time .sleep (0.25 )
1148- else :
1149- raise (Exception ("timed out waiting for unauthorized OCSP response for expired certificate. Last error: {}" .format (last_error )))
1150-
11511088def test_expiration_mailer ():
11521089 email_addr = "integration.%x@letsencrypt.org" % random .randrange (2 ** 16 )
11531090 order = chisel2 .auth_and_issue ([random_domain ()], email = email_addr )
@@ -1324,59 +1261,3 @@ def test_auth_deactivation():
13241261 resp = client .deactivate_authorization (order .authorizations [0 ])
13251262 if resp .body .status is not messages .STATUS_DEACTIVATED :
13261263 raise Exception ("unexpected authorization status" )
1327-
1328- def get_ocsp_response_and_reason (cert_file , issuer_glob , url ):
1329- """Returns the ocsp response output and revocation reason."""
1330- output = verify_ocsp (cert_file , issuer_glob , url , None )
1331- m = re .search ('Reason: (\w+)' , output )
1332- reason = m .group (1 ) if m is not None else ""
1333- return output , reason
1334-
1335- ocsp_resigning_setup_data = {}
1336- @register_twenty_days_ago
1337- def ocsp_resigning_setup ():
1338- """Issue and then revoke a cert in the past.
1339-
1340- Useful setup for test_ocsp_resigning, which needs to check that the
1341- revocation reason is still correctly set after re-signing and old OCSP
1342- response.
1343- """
1344- client = chisel2 .make_client (None )
1345- cert_file = temppath ('ocsp_resigning_setup.pem' )
1346- order = chisel2 .auth_and_issue ([random_domain ()], client = client , cert_output = cert_file .name )
1347-
1348- cert = OpenSSL .crypto .load_certificate (
1349- OpenSSL .crypto .FILETYPE_PEM , order .fullchain_pem )
1350- # Revoke for reason 5: cessationOfOperation
1351- client .revoke (josepy .ComparableX509 (cert ), 5 )
1352-
1353- ocsp_response , reason = get_ocsp_response_and_reason (
1354- cert_file .name , "test/certs/webpki/int-rsa-*.cert.pem" , "http://localhost:4002" )
1355- global ocsp_resigning_setup_data
1356- ocsp_resigning_setup_data = {
1357- 'cert_file' : cert_file .name ,
1358- 'response' : ocsp_response ,
1359- 'reason' : reason
1360- }
1361-
1362- def test_ocsp_resigning ():
1363- """Check that, after re-signing an OCSP, the reason is still set."""
1364- if 'response' not in ocsp_resigning_setup_data :
1365- raise Exception ("ocsp_resigning_setup didn't run" )
1366-
1367- tries = 0
1368- while tries < 5 :
1369- resp , reason = get_ocsp_response_and_reason (
1370- ocsp_resigning_setup_data ['cert_file' ], "test/certs/webpki/int-rsa-*.cert.pem" , "http://localhost:4002" )
1371- if resp != ocsp_resigning_setup_data ['response' ]:
1372- break
1373- tries += 1
1374- time .sleep (0.25 )
1375- else :
1376- raise (Exception ("timed out waiting for re-signed OCSP response for certificate" ))
1377-
1378- if reason != ocsp_resigning_setup_data ['reason' ]:
1379- raise (Exception ("re-signed ocsp response has different reason %s expected %s" % (
1380- reason , ocsp_resigning_setup_data ['reason' ])))
1381- if reason != "cessationOfOperation" :
1382- raise (Exception ("re-signed ocsp response has wrong reason %s" % reason ))
0 commit comments