File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed
src/DIRAC/Core/Security/m2crypto Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change 1010import random
1111import time
1212
13+ import M2Crypto .m2
14+ import M2Crypto .ASN1
1315import M2Crypto .X509
1416
1517
@@ -211,8 +213,10 @@ def getNotAfterDate(self):
211213
212214 :returns: S_OK( datetime )/S_ERROR
213215 """
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 ()
216220
217221 # M2Crypto does things correctly by setting a timezone info in the datetime
218222 # However, we do not in DIRAC, and so we can't compare the dates.
@@ -242,7 +246,10 @@ def getNotBeforeDate(self):
242246 :returns: S_OK( datetime )/S_ERROR
243247
244248 """
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 ())
246253
247254 # @executeOnlyIfCertLoaded
248255 # def setNotBefore(self, notbefore):
You can’t perform that action at this time.
0 commit comments