MCPcopy Index your code
hub / github.com/RustPython/RustPython / public_bytes

Method public_bytes

crates/stdlib/src/ssl.rs:5100–5120  ·  view source on GitHub ↗
(
            &self,
            format: OptionalArg<i32>,
            vm: &VirtualMachine,
        )

Source from the content-addressed store, hash-verified

5098 impl PySSLCertificate {
5099 #[pymethod]
5100 fn public_bytes(
5101 &self,
5102 format: OptionalArg<i32>,
5103 vm: &VirtualMachine,
5104 ) -> PyResult<PyObjectRef> {
5105 let format = format.unwrap_or(ENCODING_PEM);
5106
5107 match format {
5108 x if x == ENCODING_DER => {
5109 // Return DER bytes directly
5110 Ok(vm.ctx.new_bytes(self.der_bytes.clone()).into())
5111 }
5112 x if x == ENCODING_PEM => {
5113 // Convert DER to PEM using RFC 7468 compliant encoding
5114 let pem_str = encode_string("CERTIFICATE", LineEnding::LF, &self.der_bytes)
5115 .map_err(|e| vm.new_value_error(format!("PEM encoding failed: {e}")))?;
5116 Ok(vm.ctx.new_str(pem_str).into())
5117 }
5118 _ => Err(vm.new_value_error("Unsupported format")),
5119 }
5120 }
5121
5122 #[pymethod]
5123 fn get_info(&self, vm: &VirtualMachine) -> PyResult {

Callers 5

get_verified_chainMethod · 0.45
get_unverified_chainMethod · 0.45
get_verified_chainMethod · 0.45
get_unverified_chainMethod · 0.45

Calls 5

encode_stringFunction · 0.70
ErrClass · 0.50
new_bytesMethod · 0.45
cloneMethod · 0.45
new_strMethod · 0.45

Tested by 1