Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zhiweiyin318/grpctest
https://github.com/zhiweiyin318/grpctest
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/zhiweiyin318/grpctest
- Owner: zhiweiyin318
- Created: 2023-12-10T15:39:24.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-12-18T11:09:12.000Z (about 1 year ago)
- Last Synced: 2024-11-13T16:24:40.323Z (3 months ago)
- Language: Go
- Size: 3.52 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Example is from https://github.com/grpc/grpc-go/blob/master/examples/helloworld
1. Install protoc
https://github.com/protocolbuffers/protobuf/releases
```
protoc --version
```2. Install protoc-gen-go
```
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
protoc-gen-go --version
```3. generate proto
```
protoc helloworld/helloworld.proto --go_out=helloworld/ --go-grpc_out=helloworld/
```4. build
```
go build -o bin/server ./server
go build -o bin/client ./client
```5. run
```
./bin/server
./bin/client
```6. tls
```
openssl genrsa -out ca.key 2048openssl 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"
```