Skip to content

server: add method for retrieving client certificates #35

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
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
9 changes: 9 additions & 0 deletions src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ pub struct TlsStream<IO> {
pub(crate) state: TlsState,
}

impl<IO> TlsStream<IO> {
pub fn peer_certificates(&self) -> Option<Vec<Vec<u8>>> {
Copy link

Choose a reason for hiding this comment

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

Change this to return the Certificates either directly or by reference.

Copy link

Choose a reason for hiding this comment

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

Approving #39 which does this already.

Copy link
Author

Choose a reason for hiding this comment

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

There was already a pull request for returning the certificates directly ( #25 ) which was rejected in part because @skade didn't want to expose rustls. I think he has a point. A rustls certificate is just a Vec anyway.

Regarding references. I guess we could consider returning an iterator over &Vec here if you want to avoid copying the whole vector by default.

The commit adding documentation by @nacardin in #39 should be added though.

match self.session.get_peer_certificates() {
Some(certs) => Some(certs.into_iter().map(|cert| cert.0).collect()),
None => None,
}
}
}

pub(crate) enum MidHandshake<IO> {
Handshaking(TlsStream<IO>),
End,
Expand Down