File tree 1 file changed +10
-3
lines changed
src/DIRAC/Core/Security/m2crypto
1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change 10
10
import random
11
11
import time
12
12
13
+ import M2Crypto .m2
14
+ import M2Crypto .ASN1
13
15
import M2Crypto .X509
14
16
15
17
@@ -211,8 +213,10 @@ def getNotAfterDate(self):
211
213
212
214
:returns: S_OK( datetime )/S_ERROR
213
215
"""
214
-
215
- notAfter = self .__certObj .get_not_after ().get_datetime ()
216
+ # Here we use the M2Crypto low level API, as the high level API is notably
217
+ # slower due to the conversion to a string and then back to an ASN1_TIME.
218
+ rawNotAfter = M2Crypto .m2 .x509_get_not_after (self .__certObj .x509 ) # pylint: disable=no-member
219
+ notAfter = M2Crypto .ASN1 .ASN1_TIME (rawNotAfter ).get_datetime ()
216
220
217
221
# M2Crypto does things correctly by setting a timezone info in the datetime
218
222
# However, we do not in DIRAC, and so we can't compare the dates.
@@ -242,7 +246,10 @@ def getNotBeforeDate(self):
242
246
:returns: S_OK( datetime )/S_ERROR
243
247
244
248
"""
245
- return S_OK (self .__certObj .get_not_before ().get_datetime ())
249
+ # Here we use the M2Crypto low level API, as the high level API is notably
250
+ # slower due to the conversion to a string and then back to an ASN1_TIME.
251
+ rawNotBefore = M2Crypto .m2 .x509_get_not_before (self .__certObj .x509 ) # pylint: disable=no-member
252
+ return S_OK (M2Crypto .ASN1 .ASN1_TIME (rawNotBefore ).get_datetime ())
246
253
247
254
# @executeOnlyIfCertLoaded
248
255
# def setNotBefore(self, notbefore):
You can’t perform that action at this time.
0 commit comments