examples: make corrections to document of helloworld tls example

This commit is contained in:
ZHANG Dapeng 2018-12-03 15:08:59 -08:00 committed by GitHub
parent c31f4f1ddf
commit f5b63d703c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 9 deletions

View File

@ -47,8 +47,8 @@ USAGE: HelloWorldServerTls host port certChainFilePath privateKeyFilePath [trust
**hello-world-tls-client**: **hello-world-tls-client**:
```text ```text
USAGE: HelloWorldClientTls host port [trustCertCollectionFilePath] [clientCertChainFilePath] [clientPrivateKeyFilePath] USAGE: HelloWorldClientTls host port trustCertCollectionFilePath [clientCertChainFilePath clientPrivateKeyFilePath]
Note: clientCertChainFilePath and clientPrivateKeyFilePath are only needed if mutual auth is desired. And if you specify clientCertChainFilePath you must also specify clientPrivateKeyFilePath Note: clientCertChainFilePath and clientPrivateKeyFilePath are only needed if mutual auth is desired.
``` ```
#### Generating self-signed certificates for use with grpc #### Generating self-signed certificates for use with grpc
@ -56,6 +56,8 @@ USAGE: HelloWorldClientTls host port [trustCertCollectionFilePath] [clientCertCh
You can use the following script to generate self-signed certificates for grpc-java including the hello world with TLS examples: You can use the following script to generate self-signed certificates for grpc-java including the hello world with TLS examples:
```bash ```bash
mkdir -p /tmp/sslcert
pushd /tmp/sslcert
# Changes these CN's to match your hosts in your environment if needed. # Changes these CN's to match your hosts in your environment if needed.
SERVER_CN=localhost SERVER_CN=localhost
CLIENT_CN=localhost # Used when doing mutual TLS CLIENT_CN=localhost # Used when doing mutual TLS
@ -88,24 +90,25 @@ echo Converting the private keys to X.509:
openssl pkcs8 -topk8 -nocrypt -in client.key -out client.pem openssl pkcs8 -topk8 -nocrypt -in client.key -out client.pem
# Generates server.pem which is the privateKeyFile for the Server # Generates server.pem which is the privateKeyFile for the Server
openssl pkcs8 -topk8 -nocrypt -in server.key -out server.pem openssl pkcs8 -topk8 -nocrypt -in server.key -out server.pem
popd
``` ```
#### Hello world example with TLS (no mutual auth): #### Hello world example with TLS (no mutual auth):
```bash ```bash
# Server # Server
./build/install/examples/bin/hello-world-server-tls mate 50440 ~/Downloads/sslcert/server.crt ~/Downloads/sslcert/server.pem ./build/install/examples/bin/hello-world-tls-server localhost 50440 /tmp/sslcert/server.crt /tmp/sslcert/server.pem
# Client # Client
./build/install/examples/bin/hello-world-client-tls mate 50440 ~/Downloads/sslcert/ca.crt ./build/install/examples/bin/hello-world-tls-client localhost 50440 /tmp/sslcert/ca.crt
``` ```
#### Hello world example with TLS with mutual auth: #### Hello world example with TLS with mutual auth:
```bash ```bash
# Server # Server
./build/install/examples/bin/hello-world-server-tls mate 54440 ~/Downloads/sslcert/server.crt ~/Downloads/sslcert/server.pem ~/Downloads/sslcert/ca.crt ./build/install/examples/bin/hello-world-tls-server localhost 54440 /tmp/sslcert/server.crt /tmp/sslcert/server.pem /tmp/sslcert/ca.crt
# Client # Client
./build/install/examples/bin/hello-world-client-tls mate 54440 ~/Downloads/sslcert/ca.crt ~/Downloads/sslcert/client.crt ~/Downloads/sslcert/client.pem ./build/install/examples/bin/hello-world-tls-client localhost 54440 /tmp/sslcert/ca.crt /tmp/sslcert/client.crt /tmp/sslcert/client.pem
``` ```
That's it! That's it!

View File

@ -105,9 +105,8 @@ public class HelloWorldClientTls {
if (args.length < 2 || args.length == 4 || args.length > 5) { if (args.length < 2 || args.length == 4 || args.length > 5) {
System.out.println("USAGE: HelloWorldClientTls host port [trustCertCollectionFilePath] " + System.out.println("USAGE: HelloWorldClientTls host port [trustCertCollectionFilePath] " +
"[clientCertChainFilePath] [clientPrivateKeyFilePath]\n Note: clientCertChainFilePath and " + "[clientCertChainFilePath clientPrivateKeyFilePath]\n Note: clientCertChainFilePath and " +
"clientPrivateKeyFilePath are only needed if mutual auth is desired. And if you specify " + "clientPrivateKeyFilePath are only needed if mutual auth is desired.");
"clientCertChainFilePath you must also specify clientPrivateKeyFilePath");
System.exit(0); System.exit(0);
} }