Skip to content

chore(tonic-transport): Export TlsError #2209

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

Closed
Closed
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
2 changes: 2 additions & 0 deletions tonic/src/transport/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ mod error;
mod service;
#[cfg(feature = "_tls-any")]
mod tls;
#[cfg(feature = "_tls-any")]
pub use service::TlsError;

#[doc(inline)]
#[cfg(feature = "channel")]
Expand Down
2 changes: 2 additions & 0 deletions tonic/src/transport/service/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
pub(crate) mod grpc_timeout;
#[cfg(feature = "_tls-any")]
pub(crate) mod tls;
#[cfg(feature = "_tls-any")]
pub use tls::TlsError;

pub(crate) use self::grpc_timeout::GrpcTimeout;
8 changes: 7 additions & 1 deletion tonic/src/transport/service/tls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,19 @@ use crate::transport::{Certificate, Identity};
/// h2 alpn in plain format for rustls.
pub(crate) const ALPN_H2: &[u8] = b"h2";

/// Errors that can occur when configuring TLS.
#[derive(Debug)]
pub(crate) enum TlsError {
#[non_exhaustive]
pub enum TlsError {
/// HTTP/2 protocol was not negotiated during the TLS handshake.
#[cfg(feature = "channel")]
H2NotNegotiated,
/// No native root certificates were found on the system.
#[cfg(feature = "tls-native-roots")]
NativeCertsNotFound,
/// Failed to parse the provided TLS certificate.
CertificateParseError,
/// Failed to parse the provided private key. Only RSA and PKCS8-encoded keys are supported.
PrivateKeyParseError,
}

Expand Down