Skip to content

it is a grpc demo for study, just one module, include mutual authentication and swagger

Notifications You must be signed in to change notification settings

Fish-pro/grpc-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

grpc-demo

It's a gRPC demo, include server client and client-rest, run server, can start gRPCServer and httpServer

Run server

make run

make .go file

sh gen.sh

Certificate

Mutual authentication

Generate root certificate

openssl genrsa -out ca.key 2048
openssl req -new -x509 -days 36500 -key ca.key -out ca.pem

Server certificate

openssl genrsa -out server.key 2048
openssl req -new -key server.key -out server.csr // 本地使用localhost作为域名
openssl x509 -req -sha256 -CA ca.pem -CAkey ca.key -CAcreateserial -days 36500 -in server.csr -out server.pem

Client certificate

openssl ecparam -genkey -name secp384r1 -out client.key
openssl req -new -key client.key -out client.csr
openssl x509 -req -sha256 -CA ca.pem -CAkey ca.key -CAcreateserial -days 36500 -in client.csr -out client.pem

Swagger

Run server and access http://localhost:8080/api/

Configuration

The configuration can be modified by configuring environment variables

Environment variable name Description Default
RUN_HOST host name localhost
GRPC_PORT gRPC server port 8081
HTTP_PORT http srever port 8080
OPEN_PEM if Mutual authentication true
LOG_LEVEL log level[-1(debug)--->3(error)] -1
TIME_FORMAT log time format 2006-01-02 15:04:05
GRPC_DB_HOST database host 127.0.0.1:3306
GRPC_DB_USER database user
GRPC_DB_PASSWORD database password
GRPC_DB_NAME database name grpc-demo
CA_PATH root certificate path ~/grpc-demo/cert/ca.pem
PEM_PATH server pem path ~/grpc-demo/cert/server.pem
KEY_PATH server key path ~/grpc-demo/cert/server.key

About

it is a grpc demo for study, just one module, include mutual authentication and swagger

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages