Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 5 additions & 0 deletions src/imp/openssl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,11 @@ impl Certificate {
let der = self.0.to_der()?;
Ok(der)
}

pub fn to_pem(&self) -> Result<Vec<u8>, Error> {
let pem = self.0.to_pem()?;
Ok(pem)
}
}

pub struct MidHandshakeTlsStream<S>(MidHandshakeSslStream<S>);
Expand Down
4 changes: 4 additions & 0 deletions src/imp/schannel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,10 @@ impl Certificate {
pub fn to_der(&self) -> Result<Vec<u8>, Error> {
Ok(self.0.to_der().to_vec())
}

pub fn to_pem(&self) -> Result<Vec<u8>, Error> {
Ok(self.0.to_pem().into_bytes())
}
}

pub struct MidHandshakeTlsStream<S>(tls_stream::MidHandshakeTlsStream<S>);
Expand Down
4 changes: 4 additions & 0 deletions src/imp/security_framework.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,10 @@ impl Certificate {
pub fn to_der(&self) -> Result<Vec<u8>, Error> {
Ok(self.0.to_der())
}

pub fn to_pem(&self) -> Result<Vec<u8>, Error> {
panic!("Not implemented on macOS/iOS");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This'll need to be implemented.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems that there's currently no implementation in the underlying rust-security-framework crate. I'll see if I can do anything there.

}
}

pub enum HandshakeError<S> {
Expand Down
6 changes: 6 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,12 @@ impl Certificate {
let der = self.0.to_der()?;
Ok(der)
}

/// Returns the PEM-encoded representation of this certificate
pub fn to_pem(&self) -> Result<Vec<u8>> {
let pem = self.0.to_pem()?;
Ok(pem)
}
}

/// A TLS stream which has been interrupted midway through the handshake process.
Expand Down