File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -231,6 +231,23 @@ def write_cert_reference(path):
231231 print (refdata , file = f )
232232
233233
234+ def extract_cert (pem_cert , index ):
235+ result = []
236+ active = False
237+ for line in pem_cert .splitlines ():
238+ match = active
239+ if line == '-----BEGIN CERTIFICATE-----' :
240+ if index == 0 :
241+ active = True
242+ match = True
243+ index -= 1
244+ elif line == '-----END CERTIFICATE-----' :
245+ active = False
246+ if match :
247+ result .append (line )
248+ return '\n ' .join (result ) + '\n '
249+
250+
234251if __name__ == '__main__' :
235252 parser = argparse .ArgumentParser (description = 'Make the custom certificate and private key files used by test_ssl and friends.' )
236253 parser .add_argument ('--days' , default = days_default )
@@ -266,6 +283,10 @@ def write_cert_reference(path):
266283 f .write (key )
267284 f .write (cert )
268285
286+ cert = extract_cert (cert , 0 )
287+ with open ('cert3.pem' , 'w' ) as f :
288+ f .write (cert )
289+
269290 cert , key = make_cert_key (cmdlineargs , 'fakehostname' , sign = True )
270291 with open ('keycert4.pem' , 'w' ) as f :
271292 f .write (key )
You can’t perform that action at this time.
0 commit comments