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

fix: handle key and certificate parse errors #56

Merged
merged 1 commit into from Jun 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 5 additions & 6 deletions src/config.rs
Expand Up @@ -106,12 +106,11 @@ pub struct SerialisableCertificate {
}

impl SerialisableCertificate {
// TODO do proper error handling
pub fn obtain_priv_key_and_cert(&self) -> (quinn::PrivateKey, quinn::Certificate) {
(
unwrap!(quinn::PrivateKey::from_der(&self.key_der)),
unwrap!(quinn::Certificate::from_der(&self.cert_der)),
)
pub fn obtain_priv_key_and_cert(&self) -> R<(quinn::PrivateKey, quinn::Certificate)> {
Ok((
quinn::PrivateKey::from_der(&self.key_der)?,
quinn::Certificate::from_der(&self.cert_der)?,
))
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Expand Up @@ -311,7 +311,7 @@ impl QuicP2p {
.clone()
.unwrap_or_else(Default::default);
(
our_complete_cert.obtain_priv_key_and_cert(),
our_complete_cert.obtain_priv_key_and_cert()?,
our_complete_cert,
)
};
Expand Down