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: specific err for config w/o cert resolver #472

Merged
merged 1 commit into from
Oct 4, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ u32_enum_builder! {
NoServerCertVerifier => 7015,
NoDefaultCryptoProvider => 7016,
GetRandomFailed => 7017,
NoCertResolver => 7018,

// From https://docs.rs/rustls/latest/rustls/enum.Error.html
NoCertificatesPresented => 7101,
Expand Down Expand Up @@ -499,6 +500,9 @@ impl Display for rustls_result {
GetRandomFailed => {
write!(f, "failed to get random bytes from the crypto provider")
}
NoCertResolver => {
write!(f, "no certificate resolver was configured")
}

CertEncodingBad => Error::InvalidCertificate(CertificateError::BadEncoding).fmt(f),
CertExpired => Error::InvalidCertificate(CertificateError::Expired).fmt(f),
Expand Down
1 change: 1 addition & 0 deletions src/rustls.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ enum rustls_result {
RUSTLS_RESULT_NO_SERVER_CERT_VERIFIER = 7015,
RUSTLS_RESULT_NO_DEFAULT_CRYPTO_PROVIDER = 7016,
RUSTLS_RESULT_GET_RANDOM_FAILED = 7017,
RUSTLS_RESULT_NO_CERT_RESOLVER = 7018,
RUSTLS_RESULT_NO_CERTIFICATES_PRESENTED = 7101,
RUSTLS_RESULT_DECRYPT_ERROR = 7102,
RUSTLS_RESULT_FAILED_TO_GET_CURRENT_TIME = 7103,
Expand Down
4 changes: 2 additions & 2 deletions src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ impl rustls_server_config_builder {
let mut config = if let Some(r) = builder.cert_resolver {
base.with_cert_resolver(r)
} else {
return rustls_result::General;
return rustls_result::NoCertResolver;
};
if let Some(ss) = builder.session_storage {
config.session_storage = ss;
Expand Down Expand Up @@ -816,7 +816,7 @@ mod tests {
let mut config = null();
let result =
rustls_server_config_builder::rustls_server_config_builder_build(builder, &mut config);
assert_eq!(result, rustls_result::General);
assert_eq!(result, rustls_result::NoCertResolver);
assert!(config.is_null());
}

Expand Down
Loading