mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-09 22:49:57 +09:00
Add SSLSocket.cipher
This commit is contained in:
@@ -686,6 +686,15 @@ impl PySslSocket {
|
||||
}
|
||||
}
|
||||
|
||||
#[pymethod]
|
||||
fn cipher(&self) -> Option<CipherTuple> {
|
||||
self.stream
|
||||
.read()
|
||||
.ssl()
|
||||
.current_cipher()
|
||||
.map(cipher_to_tuple)
|
||||
}
|
||||
|
||||
#[pymethod]
|
||||
fn do_handshake(&self, vm: &VirtualMachine) -> PyResult<()> {
|
||||
let mut stream = self.stream.write();
|
||||
@@ -807,6 +816,12 @@ fn convert_ssl_error(
|
||||
vm.new_exception_msg(cls, msg.to_owned())
|
||||
}
|
||||
|
||||
type CipherTuple = (&'static str, &'static str, i32);
|
||||
|
||||
fn cipher_to_tuple(cipher: &ssl::SslCipherRef) -> CipherTuple {
|
||||
(cipher.name(), cipher.version(), cipher.bits().secret)
|
||||
}
|
||||
|
||||
fn cert_to_py(vm: &VirtualMachine, cert: &X509Ref, binary: bool) -> PyResult {
|
||||
if binary {
|
||||
cert.to_der()
|
||||
|
||||
Reference in New Issue
Block a user