From adb9b6ae4c991de633693abc59dcd68b78863191 Mon Sep 17 00:00:00 2001
From: Arnaud Ebalard <arno@natisbad.org>
Date: Tue, 16 Feb 2010 17:40:32 +0100
Subject: [PATCH] Fix to import X.509v1 Certificates (time fields)
---
scapy/all.py | 3 +--
scapy/crypto/cert.py | 16 ++++++++++++----
2 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/scapy/all.py b/scapy/all.py
index fd64c33b..fbaf017c 100644
--- a/scapy/all.py
+++ b/scapy/all.py
@@ -40,5 +40,4 @@ from asn1.asn1 import *
from asn1.ber import *
from asn1.mib import *
-
-
+from crypto.cert import *
diff --git a/scapy/crypto/cert.py b/scapy/crypto/cert.py
index dd50e777..fd33fd42 100644
--- a/scapy/crypto/cert.py
+++ b/scapy/crypto/cert.py
@@ -1715,8 +1715,12 @@ class Cert(OSSLHelper, _EncryptAndVerify):
self.notBefore_str = v
if self.notBefore_str is None:
raise Exception(error_msg)
- self.notBefore = time.strptime(self.notBefore_str,
- "%b %d %H:%M:%S %Y %Z")
+ try:
+ self.notBefore = time.strptime(self.notBefore_str,
+ "%b %d %H:%M:%S %Y %Z")
+ except:
+ self.notBefore = time.strptime(self.notBefore_str,
+ "%b %d %H:%M:%S %Y")
self.notBefore_str_simple = time.strftime("%x", self.notBefore)
# not after
@@ -1728,8 +1732,12 @@ class Cert(OSSLHelper, _EncryptAndVerify):
self.notAfter_str = v
if self.notAfter_str is None:
raise Exception(error_msg)
- self.notAfter = time.strptime(self.notAfter_str,
- "%b %d %H:%M:%S %Y %Z")
+ try:
+ self.notAfter = time.strptime(self.notAfter_str,
+ "%b %d %H:%M:%S %Y %Z")
+ except:
+ self.notAfter = time.strptime(self.notAfter_str,
+ "%b %d %H:%M:%S %Y")
self.notAfter_str_simple = time.strftime("%x", self.notAfter)
# subject
--
GitLab