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):
231
231
print (refdata , file = f )
232
232
233
233
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
+
234
251
if __name__ == '__main__' :
235
252
parser = argparse .ArgumentParser (description = 'Make the custom certificate and private key files used by test_ssl and friends.' )
236
253
parser .add_argument ('--days' , default = days_default )
@@ -266,6 +283,10 @@ def write_cert_reference(path):
266
283
f .write (key )
267
284
f .write (cert )
268
285
286
+ cert = extract_cert (cert , 0 )
287
+ with open ('cert3.pem' , 'w' ) as f :
288
+ f .write (cert )
289
+
269
290
cert , key = make_cert_key (cmdlineargs , 'fakehostname' , sign = True )
270
291
with open ('keycert4.pem' , 'w' ) as f :
271
292
f .write (key )
You can’t perform that action at this time.
0 commit comments