This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function getChannelCredentials(): ChannelCredentials { | |
| const rootCert = fs.readFileSync(path.resolve(__dirname, '../certs/ca-cert.pem')); | |
| const clientCert = fs.readFileSync(path.resolve(__dirname, '../certs/client-cert.pem')); | |
| const clientKey = fs.readFileSync(path.resolve(__dirname, '../certs/client-key.pem')); | |
| const channelCredentials = ChannelCredentials.createSsl(rootCert, clientKey, clientCert); | |
| return channelCredentials; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { ChannelCredentials } from '@grpc/grpc-js'; | |
| import * as fs from 'fs'; | |
| import * as path from 'path'; | |
| import { TLSServiceClient } from './generated/proto/tls_service'; | |
| function getChannelCredentials(): ChannelCredentials { | |
| const rootCert = fs.readFileSync(path.resolve(__dirname, '../certs/ca-cert.pem')); | |
| // If you use CA root certificate |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| services: | |
| envoy-mutual: | |
| image: envoyproxy/envoy:v1.22.0 | |
| ports: | |
| - 8080:8080 | |
| volumes: | |
| - ./envoy-mutual.yaml:/etc/envoy/envoy.yaml:ro | |
| - ./certs/ca-cert.pem:/etc/ca-cert.pem | |
| - ./certs/server-cert.pem:/etc/server-cert.pem | |
| - ./certs/server-key.pem:/etc/server-key.pem |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| services: | |
| envoy-server: | |
| image: envoyproxy/envoy:v1.22.0 | |
| ports: | |
| - 8080:8080 | |
| volumes: | |
| - ./envoy-server.yaml:/etc/envoy/envoy.yaml:ro | |
| - ./certs/server-cert.pem:/etc/server-cert.pem | |
| - ./certs/server-key.pem:/etc/server-key.pem |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| static_resources: | |
| listeners: | |
| - name: listener_0 | |
| address: | |
| socket_address: { address: 0.0.0.0, port_value: 8080 } | |
| filter_chains: | |
| - filters: | |
| - name: envoy.filters.network.http_connection_manager | |
| typed_config: | |
| "@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| static_resources: | |
| listeners: | |
| - name: listener_0 | |
| address: | |
| socket_address: { address: 0.0.0.0, port_value: 8080 } | |
| filter_chains: | |
| - filters: | |
| - name: envoy.filters.network.http_connection_manager | |
| typed_config: | |
| "@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function getServerCredentials(): ServerCredentials { | |
| const rootCert = fs.readFileSync(path.resolve(__dirname, '../certs/ca-cert.pem')); | |
| const serverCert = fs.readFileSync(path.resolve(__dirname, '../certs/server-cert.pem')); | |
| const serverKey = fs.readFileSync(path.resolve(__dirname, '../certs/server-key.pem')); | |
| const serverCredentials = ServerCredentials.createSsl( | |
| rootCert, | |
| [ | |
| { | |
| cert_chain: serverCert, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Server, ServerCredentials } from '@grpc/grpc-js'; | |
| import * as fs from 'fs'; | |
| import * as path from 'path'; | |
| import { TLSServiceServer, TLSServiceService } from './generated/proto/tls_service'; | |
| const TLSService: TLSServiceServer = { | |
| unary(call, callback) { | |
| callback(null, call.request); | |
| }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| syntax = "proto3"; | |
| package tls_service.v1; | |
| message SimpleMessage { | |
| string id = 1; | |
| } | |
| service TLSService { | |
| rpc Unary(SimpleMessage) returns (SimpleMessage); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| rm *.pem | |
| rm *.srl | |
| rm *.cnf | |
| # 1. Generate CA's private key and self-signed certificate | |
| openssl req -x509 -newkey rsa:4096 -days 365 -nodes -keyout ca-key.pem -out ca-cert.pem -subj "/C=FR/ST=Occitanie/L=Toulouse/O=Test Org/OU=Test/CN=*.test/[email protected]" | |
| echo "CA's self-signed certificate" | |
| openssl x509 -in ca-cert.pem -noout -text |