pex.ssl.openssl
¶
Module Contents¶
- class pex.ssl.openssl.OpenSSL¶
Bases:
object
Subclass of pex.ssl module.
This subclass of pex.ssl module is intended for providing Python realization of OpenSSL library.
- wrap_client(client: socket.socket, keyfile: str = 'hatsploit.key', certfile: str = 'hatsploit.crt', protocol: ssl._SSLMethod = ssl.PROTOCOL_TLS, expire: int = 365, nodename: str = 'HatSploit', country: str = 'US', state: str = 'HatSploit', location: str = 'HatSploit', organization: str = 'HatSploit', unit: str = 'HatSploit', server: bool = True) ssl.SSLSocket ¶
Generate a certificate and wrap a socket with it.
- Parameters:
client (socket.socket) – socket client
keyfile (str) – path to the output key file
certfile (str) – path to the output certificate file
protocol (ssl._SSLMethod) – protocol type
expire (int) – certificate expiration limit
nodename (str) – certificate nodename
country (str) – certificate country
state (str) – certificate state
location (str) – certificate location
organization (str) – certificate organization
unit (str) – certificate unit
server (bool) – True if server side else False
- Return ssl.SSLSocket:
wrapped socket
- write_key(key: OpenSSL.crypto.PKey, filename: str) None ¶
Write generated key to a file.
- Parameters:
key (crypto.PKey) – generated key to write
filename (str) – name of file to write to
- Return None:
None
- write_cert(cert: OpenSSL.crypto.X509, filename: str) None ¶
Write generated certificate to a file.
- Parameters:
cert (crypto.X509) – generated certificate to write
filename (str) – name of file to write to
- Return None:
None
- static dump_key(key: OpenSSL.crypto.PKey) bytes ¶
Dump generated key contents.
- Parameters:
key (crypto.PKey) – generated key to dump
- Return bytes:
generated key contents
- static dump_cert(cert: OpenSSL.crypto.X509) bytes ¶
Dump generated certificate contents.
- Parameters:
cert (crypto.X509) – generated certificate to dump
- Return bytes:
generated certificate contents
- static generate_key() OpenSSL.crypto.PKey ¶
Generate key.
- Return crypto.PKey:
generated key
- static generate_cert(key: OpenSSL.crypto.PKey, expire: int = 365, nodename: str = 'HatSploit', country: str = 'US', state: str = 'HatSploit', location: str = 'HatSploit', organization: str = 'HatSploit', unit: str = 'HatSploit') OpenSSL.crypto.X509 ¶
Generate certificate.
- Parameters:
key (crypto.PKey) – generated key
expire (int) – certificate expiration limit
nodename (str) – certificate nodename
country (str) – certificate country
state (str) – certificate state
location (str) – certificate location
organization (str) – certificate organization
unit (str) – certificate unit
- Return crypto.X509:
generated certificate