@@ -405,12 +405,12 @@ def create_temporary_ca_path(anchor_list, folder):
405
405
406
406
class OSSLHelper :
407
407
def _apply_ossl_cmd (self , osslcmd , rawdata ):
408
- r ,w = popen2 .popen2 (osslcmd )
409
- w .write (rawdata )
410
- w .close ()
411
- res = r .read ()
412
- r .close ()
413
- return res
408
+ r ,w = popen2 .popen2 (osslcmd )
409
+ w .write (rawdata )
410
+ w .close ()
411
+ res = r .read ()
412
+ r .close ()
413
+ return res
414
414
415
415
class _EncryptAndVerify :
416
416
### Below are encryption methods
@@ -1183,14 +1183,14 @@ def __init__(self, keypath):
1183
1183
rawkey = f .read ()
1184
1184
f .close ()
1185
1185
except :
1186
- raise Exception (error_msg )
1186
+ raise Exception (error_msg )
1187
1187
else :
1188
1188
rawkey = keypath
1189
1189
1190
- if rawkey is None :
1191
- raise Exception (error_msg )
1190
+ if rawkey is None :
1191
+ raise Exception (error_msg )
1192
1192
1193
- self .rawkey = rawkey
1193
+ self .rawkey = rawkey
1194
1194
1195
1195
# Let's try to get file format : PEM or DER.
1196
1196
fmtstr = 'openssl rsa -text -pubin -inform %s -noout '
@@ -1228,15 +1228,15 @@ def __init__(self, keypath):
1228
1228
textkey = r .read ()
1229
1229
r .close ()
1230
1230
res = e .read ()
1231
- if res == '' :
1232
- self .format = "DER"
1231
+ if res == '' :
1232
+ self .format = "DER"
1233
1233
self .derkey = rawkey
1234
1234
self .textkey = textkey
1235
1235
cmd = convertstr % ("DER" , "PEM" )
1236
1236
self .pemkey = self ._apply_ossl_cmd (cmd , rawkey )
1237
1237
cmd = convertstr % ("DER" , "DER" )
1238
1238
self .derkey = self ._apply_ossl_cmd (cmd , rawkey )
1239
- else :
1239
+ else :
1240
1240
try : # Perhaps it is a cert
1241
1241
c = Cert (keypath )
1242
1242
except :
@@ -1343,14 +1343,14 @@ def __init__(self, keypath):
1343
1343
rawkey = f .read ()
1344
1344
f .close ()
1345
1345
except :
1346
- raise Exception (error_msg )
1346
+ raise Exception (error_msg )
1347
1347
else :
1348
1348
rawkey = keypath
1349
1349
1350
- if rawkey is None :
1351
- raise Exception (error_msg )
1350
+ if rawkey is None :
1351
+ raise Exception (error_msg )
1352
1352
1353
- self .rawkey = rawkey
1353
+ self .rawkey = rawkey
1354
1354
1355
1355
# Let's try to get file format : PEM or DER.
1356
1356
fmtstr = 'openssl rsa -text -inform %s -noout '
@@ -1388,16 +1388,16 @@ def __init__(self, keypath):
1388
1388
textkey = r .read ()
1389
1389
r .close ()
1390
1390
res = e .read ()
1391
- if res == '' :
1392
- self .format = "DER"
1391
+ if res == '' :
1392
+ self .format = "DER"
1393
1393
self .derkey = rawkey
1394
1394
self .textkey = textkey
1395
1395
cmd = convertstr % ("DER" , "PEM" )
1396
1396
self .pemkey = self ._apply_ossl_cmd (cmd , rawkey )
1397
1397
cmd = convertstr % ("DER" , "DER" )
1398
1398
self .derkey = self ._apply_ossl_cmd (cmd , rawkey )
1399
- else :
1400
- raise Exception (error_msg )
1399
+ else :
1400
+ raise Exception (error_msg )
1401
1401
1402
1402
self .osslcmdbase = 'openssl rsa -inform %s ' % self .format
1403
1403
@@ -1534,14 +1534,14 @@ def __init__(self, certpath):
1534
1534
rawcert = f .read ()
1535
1535
f .close ()
1536
1536
except :
1537
- raise Exception (error_msg )
1537
+ raise Exception (error_msg )
1538
1538
else :
1539
1539
rawcert = certpath
1540
1540
1541
- if rawcert is None :
1542
- raise Exception (error_msg )
1541
+ if rawcert is None :
1542
+ raise Exception (error_msg )
1543
1543
1544
- self .rawcert = rawcert
1544
+ self .rawcert = rawcert
1545
1545
1546
1546
# Let's try to get file format : PEM or DER.
1547
1547
fmtstr = 'openssl x509 -text -inform %s -noout '
@@ -1579,16 +1579,16 @@ def __init__(self, certpath):
1579
1579
textcert = r .read ()
1580
1580
r .close ()
1581
1581
res = e .read ()
1582
- if res == '' :
1583
- self .format = "DER"
1582
+ if res == '' :
1583
+ self .format = "DER"
1584
1584
self .dercert = rawcert
1585
1585
self .textcert = textcert
1586
1586
cmd = convertstr % ("DER" , "PEM" )
1587
1587
self .pemcert = self ._apply_ossl_cmd (cmd , rawcert )
1588
1588
cmd = convertstr % ("DER" , "DER" )
1589
1589
self .dercert = self ._apply_ossl_cmd (cmd , rawcert )
1590
- else :
1591
- raise Exception (error_msg )
1590
+ else :
1591
+ raise Exception (error_msg )
1592
1592
1593
1593
self .osslcmdbase = 'openssl x509 -inform %s ' % self .format
1594
1594
@@ -1823,7 +1823,7 @@ def __init__(self, certpath):
1823
1823
# X509v3 Key Usage
1824
1824
self .keyUsage = []
1825
1825
v = fields_dict [" X509v3 Key Usage:" ]
1826
- if v :
1826
+ if v :
1827
1827
# man 5 x509v3_config
1828
1828
ku_mapping = {"Digital Signature" : "digitalSignature" ,
1829
1829
"Non Repudiation" : "nonRepudiation" ,
@@ -1848,7 +1848,7 @@ def __init__(self, certpath):
1848
1848
# X509v3 Extended Key Usage
1849
1849
self .extKeyUsage = []
1850
1850
v = fields_dict [" X509v3 Extended Key Usage:" ]
1851
- if v :
1851
+ if v :
1852
1852
# man 5 x509v3_config:
1853
1853
eku_mapping = {"TLS Web Server Authentication" : "serverAuth" ,
1854
1854
"TLS Web Client Authentication" : "clientAuth" ,
@@ -2016,7 +2016,7 @@ def remainingDays(self, now=None):
2016
2016
# return SHA-1 hash of cert embedded public key
2017
2017
# !! At the moment, the trailing 0 is in the hashed string if any
2018
2018
def keyHash (self ):
2019
- m = self .modulus_hexdump
2019
+ m = self .modulus_hexdump
2020
2020
res = []
2021
2021
i = 0
2022
2022
l = len (m )
@@ -2230,14 +2230,14 @@ def __init__(self, crlpath):
2230
2230
rawcrl = f .read ()
2231
2231
f .close ()
2232
2232
except :
2233
- raise Exception (error_msg )
2233
+ raise Exception (error_msg )
2234
2234
else :
2235
2235
rawcrl = crlpath
2236
2236
2237
- if rawcrl is None :
2238
- raise Exception (error_msg )
2237
+ if rawcrl is None :
2238
+ raise Exception (error_msg )
2239
2239
2240
- self .rawcrl = rawcrl
2240
+ self .rawcrl = rawcrl
2241
2241
2242
2242
# Let's try to get file format : PEM or DER.
2243
2243
fmtstr = 'openssl crl -text -inform %s -noout '
@@ -2275,16 +2275,16 @@ def __init__(self, crlpath):
2275
2275
textcrl = r .read ()
2276
2276
r .close ()
2277
2277
res = e .read ()
2278
- if res == '' :
2279
- self .format = "DER"
2278
+ if res == '' :
2279
+ self .format = "DER"
2280
2280
self .dercrl = rawcrl
2281
2281
self .textcrl = textcrl
2282
2282
cmd = convertstr % ("DER" , "PEM" )
2283
2283
self .pemcrl = self ._apply_ossl_cmd (cmd , rawcrl )
2284
2284
cmd = convertstr % ("DER" , "DER" )
2285
2285
self .dercrl = self ._apply_ossl_cmd (cmd , rawcrl )
2286
- else :
2287
- raise Exception (error_msg )
2286
+ else :
2287
+ raise Exception (error_msg )
2288
2288
2289
2289
self .osslcmdbase = 'openssl crl -inform %s ' % self .format
2290
2290
@@ -2475,4 +2475,3 @@ def verify(self, anchors):
2475
2475
2476
2476
2477
2477
2478
-
0 commit comments