Refactor all of the tls

This commit is contained in:
Lucio Franco
2019-09-24 14:32:16 -04:00
parent ffba9ef6d2
commit 60c9629630
19 changed files with 376 additions and 322 deletions
+4 -3
View File
@@ -1,6 +1,6 @@
use std::time::Duration;
use structopt::{clap::arg_enum, StructOpt};
use tonic::transport::Endpoint;
use tonic::transport::{Certificate, Endpoint};
use tonic_interop::client;
#[derive(StructOpt)]
@@ -31,8 +31,9 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
.clone();
if matches.use_tls {
let ca = tokio::fs::read("tonic-interop/data/ca.pem").await?;
endpoint.tls_cert(ca, Some("foo.test.google.fr".into()));
let pem = tokio::fs::read("tonic-interop/data/ca.pem").await?;
let ca = Certificate::from_pem(pem);
endpoint.openssl_tls(ca, Some("foo.test.google.fr".into()));
}
let channel = endpoint.channel()?;
+5 -3
View File
@@ -1,5 +1,5 @@
use structopt::StructOpt;
use tonic::Server;
use tonic::transport::{Identity, Server};
use tonic_interop::{server, MergeTrailers};
// TODO: move GrpcService out of client since it can be used for the
// server too.
@@ -24,9 +24,11 @@ async fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
let mut builder = Server::builder();
if matches.use_tls {
let ca = tokio::fs::read("tonic-interop/data/server1.pem").await?;
let cert = tokio::fs::read("tonic-interop/data/server1.pem").await?;
let key = tokio::fs::read("tonic-interop/data/server1.key").await?;
builder.tls(ca, key);
let identity = Identity::from_pem(cert, key);
builder.openssl_tls(identity);
}
builder.interceptor_fn(|svc, req| {