Heya :-)
Note that you can replace the following
On 14.10.2011 00:30, Owen Taylor wrote:
> process = subprocess.Popen(['openssl', 's_client', '-host', host, '-port', '443'],
> stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE)
> output, error = process.communicate("")
> if process.returncode != 0:
> print "Failed to download cert from", host
> print error
> return None
>
> cert_lines = []
>
> i = output.split('\n').__iter__()
>
> for line in i:
> if re.match('-----BEGIN CERTIFICATE-----', line):
> cert_lines.append(line)
> break
>
> for line in i:
> cert_lines.append(line)
> if re.match('-----END CERTIFICATE-----', line):
> break
>
> cert = '\n'.join(cert_lines)
With smth like:
import ssl
addr_port = (settings.SERVER_ADDRESS,
settings.SERVER_SSL_PORT)
cert = ssl.get_server_certificate(addr_port)
Cheers,
Tobi
Attachment:
signature.asc
Description: OpenPGP digital signature