Example is from https://github.com/grpc/grpc-go/blob/master/examples/helloworld
- Install protoc
https://github.com/protocolbuffers/protobuf/releases
protoc --version
- Install protoc-gen-go
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
protoc-gen-go --version
- generate proto
protoc helloworld/helloworld.proto --go_out=helloworld/ --go-grpc_out=helloworld/
- build
go build -o bin/server ./server
go build -o bin/client ./client
- run
./bin/server
./bin/client
- tls
openssl genrsa -out ca.key 2048
openssl req -new -x509 -days 36500 -key ca.key -out ca.crt -config openssl.cnf
openssl genrsa -out server.key 2048
openssl req -new -key server.key -out server.csr -config openssl.cnf
openssl x509 -req -days 36500 -in server.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out server.crt -extfile <(printf "subjectAltName=IP.1:127.0.0.1")
go run server/server.go --cert="tls/server.crt" --key="tls/server.key"
go run client/client.go --ca="tls/ca.crt" --addr="https://127.0.0.1:50051"