Skip to content

Commit

Permalink
Add note on conversion. Use error fn
Browse files Browse the repository at this point in the history
  • Loading branch information
augustuswm committed Feb 16, 2024
1 parent 4ce62b7 commit 70a51c3
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions nexus/db-model/src/certificate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,16 @@ impl TryFrom<Certificate> for views::Certificate {
Ok(Self {
identity: cert.identity(),
service: cert.service.try_into()?,
cert: String::from_utf8(cert.cert)
.map_err(|err| {
Error::InternalError {
internal_message: format!(
"Failed to construct string from stored certificate: {}",
err
)
}
}
)?,
// This is expected to succeed in normal circumstances. Certificates are stored in the
// database with PEM encoding which are essentially bundles of Base64 encoded text.
// The only cases in which this conversion should fail is when our internal database
// representation of the certificate is invalid.
cert: String::from_utf8(cert.cert).map_err(|err| {
Error::internal_error(&format!(
"Failed to construct string from stored certificate: {}",
err
))
})?,
})
}
}

0 comments on commit 70a51c3

Please sign in to comment.