Cache call to openssl ciphers
This commit is contained in:
parent
9cfd1e1831
commit
c28b688943
@ -6,6 +6,7 @@ import ssl
|
|||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
_cipher_cache = dict()
|
||||||
|
|
||||||
def get(subset="ALL:COMPLEMENTOFALL"):
|
def get(subset="ALL:COMPLEMENTOFALL"):
|
||||||
"""Ask OpenSSL a list of ciphers
|
"""Ask OpenSSL a list of ciphers
|
||||||
@ -14,12 +15,16 @@ def get(subset="ALL:COMPLEMENTOFALL"):
|
|||||||
subset -- an openssl cipher list format string
|
subset -- an openssl cipher list format string
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
if subset in _cipher_cache:
|
||||||
|
return _cipher_cache[subset]
|
||||||
|
|
||||||
ciphers = []
|
ciphers = []
|
||||||
with subprocess.Popen(["openssl", "ciphers", subset],
|
with subprocess.Popen(["openssl", "ciphers", subset],
|
||||||
stdout=subprocess.PIPE) as raw_ciphers:
|
stdout=subprocess.PIPE) as raw_ciphers:
|
||||||
ciphers = re.findall(r"[^:]+",
|
ciphers = re.findall(r"[^:]+",
|
||||||
raw_ciphers.stdout.read().strip().decode())
|
raw_ciphers.stdout.read().strip().decode())
|
||||||
|
|
||||||
|
_cipher_cache[subset] = ciphers
|
||||||
return ciphers
|
return ciphers
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user