Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix ssl
  • Loading branch information
youknowone committed Dec 23, 2025
commit 73e1c3816e737b0559063c44f52537d6963aa267
14 changes: 10 additions & 4 deletions crates/stdlib/src/openssl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1543,10 +1543,10 @@ mod _ssl {
#[pymethod]
fn get_ca_certs(
&self,
binary_form: OptionalArg<bool>,
args: GetCertArgs,
vm: &VirtualMachine,
) -> PyResult<Vec<PyObjectRef>> {
let binary_form = binary_form.unwrap_or(false);
let binary_form = args.binary_form.unwrap_or(false);
let ctx = self.ctx();
#[cfg(ossl300)]
let certs = ctx.cert_store().all_certificates();
Expand Down Expand Up @@ -2259,6 +2259,12 @@ mod _ssl {
password: Option<PyObjectRef>,
}

#[derive(FromArgs)]
struct GetCertArgs {
#[pyarg(any, optional)]
binary_form: OptionalArg<bool>,
}

// Err is true if the socket is blocking
type SocketDeadline = Result<Instant, bool>;

Expand Down Expand Up @@ -2516,10 +2522,10 @@ mod _ssl {
#[pymethod]
fn getpeercert(
&self,
binary: OptionalArg<bool>,
args: GetCertArgs,
vm: &VirtualMachine,
) -> PyResult<Option<PyObjectRef>> {
let binary = binary.unwrap_or(false);
let binary = args.binary_form.unwrap_or(false);
let stream = self.connection.read();
if !stream.ssl().is_init_finished() {
return Err(vm.new_value_error("handshake not done yet"));
Expand Down
18 changes: 10 additions & 8 deletions crates/stdlib/src/ssl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -841,6 +841,12 @@ mod _ssl {
password: OptionalArg<PyObjectRef>,
}

#[derive(FromArgs)]
struct GetCertArgs {
#[pyarg(any, optional)]
binary_form: OptionalArg<bool>,
}

#[pyclass(with(Constructor), flags(BASETYPE))]
impl PySSLContext {
// Helper method to convert DER certificate bytes to Python dict
Expand Down Expand Up @@ -1688,12 +1694,8 @@ mod _ssl {
}

#[pymethod]
fn get_ca_certs(
&self,
binary_form: OptionalArg<bool>,
vm: &VirtualMachine,
) -> PyResult<PyListRef> {
let binary_form = binary_form.unwrap_or(false);
fn get_ca_certs(&self, args: GetCertArgs, vm: &VirtualMachine) -> PyResult<PyListRef> {
let binary_form = args.binary_form.unwrap_or(false);
let ca_certs_der = self.ca_certs_der.read();

let mut certs = Vec::new();
Expand Down Expand Up @@ -3444,10 +3446,10 @@ mod _ssl {
#[pymethod]
fn getpeercert(
&self,
binary_form: OptionalArg<bool>,
args: GetCertArgs,
vm: &VirtualMachine,
) -> PyResult<Option<PyObjectRef>> {
let binary = binary_form.unwrap_or(false);
let binary = args.binary_form.unwrap_or(false);

// Check if handshake is complete
if !*self.handshake_done.lock() {
Expand Down