github.com/godaddy-x/freego@v1.0.156/rpcx/README.md (about) 1 ## 1. 2 go get -u google.golang.org/grpc 3 go get -u google.golang.org/protobuf 4 5 ## 2. 6 go install google.golang.org/protobuf/cmd/protoc-gen-go@latest 7 go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest 8 9 ## 3. 10 protoc --go_out=. ./rpcx/proto/pub_worker.proto 11 protoc --go-grpc_out=. ./rpcx/proto/pub_worker.proto 12 13 ## 4. 生成TLS证书 14 15 ### 生成ca私钥 16 openssl genrsa -out ca.key 4096 17 ### 自签名生成ca.crt 证书文件 18 ### 如果在 Windows 使用 Git Bash 出现错误 19 ### name is expected to be in the format /type0=value0/type1=value1/type2=... where characters may be escaped by \. This name is not in that format: ... 20 ### 则需要在命令前加上 21 ### MSYS_NO_PATHCONV=1 22 ### 例如 MSYS_NO_PATHCONV=1 openssl ... 23 MSYS_NO_PATHCONV=1 openssl req -new -x509 -days 3650 -key ca.key -out ca.crt -subj "/CN=localhost" 24 ### 生成server/client key file 25 openssl genrsa -out server.key 2048 26 openssl genrsa -out client.key 2048 27 ### 生成server/client csr file 28 openssl req -new -key server.key -out server.csr -config TLS.md -extensions SAN 29 openssl req -new -key client.key -out client.csr -config TLS.md -extensions SAN 30 ### 生成server/client crt file 31 ### Generates server.crt which is the certChainFile for the server 32 openssl x509 -req -days 3650 -in server.csr -CA ca.crt -CAkey ca.key -set_serial 01 -out server.crt -extfile TLS.md -extensions SAN 33 openssl x509 -req -days 3650 -in client.csr -CA ca.crt -CAkey ca.key -set_serial 01 -out client.crt -extfile TLS.md -extensions SAN 34 ### Generates server.pem which is the privateKeyFile for the Server 35 openssl pkcs8 -topk8 -nocrypt -in server.key -out server.pem 36 37 38 ### 独立server.key进行SAN自签 39 openssl genrsa -out server.key 2048 40 openssl req -new -key server.key -out server.csr -config TLS.md -extensions SAN 41 openssl x509 -req -days 3650 -in server.csr -set_serial 01 -signkey server.key -out server.crt -extfile TLS.md -extensions SAN