Skip to content

Commit

Permalink
Fix locale problem in wptserve.
Browse files Browse the repository at this point in the history
  • Loading branch information
pulkomandy committed Sep 1, 2019
1 parent b27a4f8 commit 958af2e
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import shutil
import subprocess
import tempfile
import locale
from datetime import datetime, timedelta

from six import iteritems
Expand Down Expand Up @@ -309,12 +310,13 @@ def check_key_cert(self, key_path, cert_path, hosts):
if not os.path.exists(key_path) or not os.path.exists(cert_path):
return False

locale.setlocale(locale.LC_ALL, 'C')

with self._config_openssl(hosts) as openssl:
end_date_str = openssl("x509",
"-noout",
"-enddate",
"-in", cert_path).split("=", 1)[1].strip()
# Not sure if this works in other locales
end_date = datetime.strptime(end_date_str, "%b %d %H:%M:%S %Y %Z")
time_buffer = timedelta(**CERT_EXPIRY_BUFFER)
# Because `strptime` does not account for time zone offsets, it is
Expand Down

0 comments on commit 958af2e

Please sign in to comment.