Page Summary
-
The server implementation requires specific
google-protobufandgrpcgems, and a defined directory structure including a downloadedbooking_service.protofile. -
Ruby libraries must be generated from the
booking_service.protousing thegrpc_tools_ruby_protoccommand. -
For initial testing, the server can be run with TLS disabled using
--disable_tls, though this is not suitable for production. -
Production servers require TLS, necessitating
server.pem,server.key, andtrusted_client_roots.pemfiles in thecertificatesdirectory. -
The final directory structure includes generated Ruby files (
booking_service_pb.rbandbooking_service_services_pb.rb) within thelibdirectory, alongside the certificate files.
Prerequisites
Gems required for the server implementation:
- google-protobuf (3.2.X used in this tutorial)
- grpc (1.2.X used in this tutorial)
Download the service definition and create this directory structure:
[base_dir]
├── certificates
├── lib
├── protos
└── booking_service.proto
└── server.rb
Generate Ruby libraries from the interface description:
$ cd [base_dir]
$ grpc_tools_ruby_protoc -I protos --ruby_out=lib --grpc_out=lib protos/booking_service.proto
Implement the server
If you need the skeleton code, ask a Google POC.
Test the server without TLS
For initial testing, TLS can be disabled:
$ cd [base_dir]
$ ruby server.rb --disable_tls
This is unsuitable for production use!
Configure production certificates
To enable TLS on the server, the following files are required:
certificates/server.pemthe certificate chain for the server in in PEM formatcertificates/server.keythe private key for the server certificate chaincertificates/trusted_client_roots.pemthe root certificates that are trusted when authenticating clients
The set of trusted client root certificates is used when authenticating the client. You can choose to obtain this set of trusted roots from an authority like Mozilla or install the set of roots currently recommended by the Google Internet Authority G2. In the latter case, you may have to manually update the root certificate at times.
Final directory structure
[base_dir]
├── certificates
├── server.pem
├── server.key
└── trusted_client_roots.pem
├── lib
├── booking_service_pb.rb
└── booking_service_services_pb.rb
├── protos
└── booking_service.proto
└── server.rb