-
-
Notifications
You must be signed in to change notification settings - Fork 203
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
TlsStream::certificate_chain, ChainIterator type and Certificate::public_key_info_der #117
base: master
Are you sure you want to change the base?
Changes from all commits
c3e2615
d5caf12
3982c58
c978e57
6de69bd
ee90227
bdfb49e
7c44234
5777ab2
cc76bf1
0cf0372
d3a6925
05cc92f
fec0d51
07ac327
bfbbb0f
6c441af
deefe6b
38aa40e
3016bc2
ff5fb62
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -206,6 +206,23 @@ impl Certificate { | |
let der = self.0.to_der()?; | ||
Ok(der) | ||
} | ||
|
||
/// Returns der encoded subjectPublicKeyInfo. | ||
pub fn public_key_info_der(&self) -> Result<Vec<u8>> { | ||
let der = self.0.public_key_info_der()?; | ||
Ok(der) | ||
} | ||
} | ||
|
||
/// An iterator over a certificate chain. | ||
pub struct ChainIterator<'a, S: 'a>(imp::ChainIterator<'a, S>); | ||
|
||
impl<'a, S> Iterator for ChainIterator<'a, S> { | ||
type Item = Certificate; | ||
|
||
fn next(&mut self) -> Option<Self::Item> { | ||
self.0.next().map(Certificate) | ||
} | ||
} | ||
|
||
/// A TLS stream which has been interrupted midway through the handshake process. | ||
|
@@ -630,6 +647,11 @@ impl<S: io::Read + io::Write> TlsStream<S> { | |
Ok(self.0.peer_certificate()?.map(Certificate)) | ||
} | ||
|
||
/// Returns an iterator over certificate chain. It may be an empty iterator if chain not available. | ||
pub fn certificate_chain(&mut self) -> Result<ChainIterator<S>> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we distinguish the "no chain present" case here by returning something like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would prefer to create an empty iterator that just returns None immediately. That is what happens in the downstream crates. Result<Option> is a pretty annoying API. |
||
Ok(ChainIterator(self.0.certificate_chain()?)) | ||
} | ||
|
||
/// Returns the tls-server-end-point channel binding data as defined in [RFC 5929]. | ||
/// | ||
/// [RFC 5929]: https://tools.ietf.org/html/rfc5929 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to stop at the end of the chain, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trust will return None once it is over limit.