Skip to content
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

server: add method for retrieving client certificates #39

Closed
wants to merge 4 commits 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
12 changes: 11 additions & 1 deletion src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::rusttls::stream::Stream;

use futures_core::ready;
use futures_io::{AsyncRead, AsyncWrite};
use rustls::ServerSession;
use rustls::{Certificate, ServerSession};
use std::future::Future;
use std::pin::Pin;
use std::task::{Context, Poll};
Expand All @@ -22,6 +22,16 @@ pub struct TlsStream<IO> {
pub(crate) state: TlsState,
}

impl<IO> TlsStream<IO> {
/// Retrieves the certificate chain used by the client,
/// if client authentication was completed.
///
/// The return value is None until this value is available.
pub fn client_certificates(&self) -> Option<Vec<Certificate>> {
self.session.get_peer_certificates()
}
}

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