| Crates.io | mtls-grpc |
| lib.rs | mtls-grpc |
| version | 0.1.0 |
| created_at | 2026-01-01 15:52:16.342899+00 |
| updated_at | 2026-01-01 15:52:16.342899+00 |
| description | gRPC adapter for mTLS authentication with IP whitelisting |
| homepage | |
| repository | https://github.com/Crellsin/mtls-rs |
| max_upload_size | |
| id | 2016362 |
| size | 54,265 |
gRPC adapter for mTLS authentication with IP whitelisting (Work in Progress).
mtls-grpc provides gRPC (tonic) interceptors and credentials for integrating mTLS (mutual TLS) authentication and IP whitelisting into your gRPC applications. This crate is currently a work in progress and serves as a placeholder for future gRPC mTLS integration.
⚠️ Experimental: This crate is currently a skeleton implementation. The actual gRPC mTLS integration will be added once the underlying tonic version and its API are stabilized for mTLS.
Add to your Cargo.toml:
[dependencies]
mtls-grpc = "0.1.0"
mtls-core = "0.1.0"
use tonic::transport::Server;
use mtls_grpc::ServerCredentials;
use mtls_core::validator::ConnectionValidator;
use mtls_core::config::ServerConfig;
use std::path::Path;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Configure mTLS server
let server_config = ServerConfig::new(
Path::new("certs/server.crt"),
Path::new("certs/server.key"),
Path::new("certs/ca.crt"),
);
// Create connection validator
let validator = ConnectionValidator::create_for_server(server_config)?;
// Create gRPC server credentials
let credentials = ServerCredentials::new(validator);
// Build gRPC server with mTLS
Server::builder()
.tls_config(credentials.into_tls_config()?)?
.add_service(YourServiceServer::new(YourService))
.serve("127.0.0.1:50051".parse()?)
.await?;
Ok(())
}
use tonic::transport::Channel;
use mtls_grpc::ClientCredentials;
use mtls_core::validator::ConnectionValidator;
use mtls_core::config::ClientConfig;
use std::path::Path;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Configure mTLS client
let client_config = ClientConfig::new(
Path::new("certs/client.crt"),
Path::new("certs/client.key"),
)
.with_ca_cert_path(Path::new("certs/ca.crt"));
// Create connection validator
let validator = ConnectionValidator::create_for_client(client_config)?;
// Create gRPC client credentials
let credentials = ClientCredentials::new(validator);
// Create channel with mTLS
let channel = Channel::from_static("https://127.0.0.1:50051")
.tls_config(credentials.into_tls_config()?)?
.connect()
.await?;
// Use channel to create gRPC client
// let client = YourServiceClient::new(channel);
Ok(())
}
The current implementation provides placeholder structs that will be expanded in future releases:
// Placeholder structs - to be implemented
pub struct ServerCredentials { /* ... */ }
pub struct ClientCredentials { /* ... */ }
pub struct MtlsInterceptor { /* ... */ }
Contributions are welcome! Since this crate is in early development, we particularly welcome:
Please see the main project repository for contribution guidelines.
licensed under:
This crate depends on the mtls-core crate for certificate and IP validation. The actual gRPC/Tonic integration will be implemented as the underlying libraries stabilize their mTLS support.