GRPC C++  1.66.0
server_credentials.h
Go to the documentation of this file.
1 //
2 //
3 // Copyright 2015 gRPC authors.
4 //
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 //
18 
19 #ifndef GRPCPP_SECURITY_SERVER_CREDENTIALS_H
20 #define GRPCPP_SECURITY_SERVER_CREDENTIALS_H
21 
22 #include <memory>
23 #include <vector>
24 
29 #include <grpcpp/support/config.h>
30 
31 struct grpc_server;
32 
33 namespace grpc {
34 
35 class Server;
36 class ServerCredentials;
37 
42  : force_client_auth(false),
46  : force_client_auth(false), client_certificate_request(request_type) {}
47 
48  struct PemKeyCertPair {
49  std::string private_key;
50  std::string cert_chain;
51  };
52  std::string pem_root_certs;
53  std::vector<PemKeyCertPair> pem_key_cert_pairs;
56 
62 };
63 
65 std::shared_ptr<ServerCredentials> XdsServerCredentials(
66  const std::shared_ptr<ServerCredentials>& fallback_credentials);
67 
70  public:
71  ~ServerCredentials() override;
72 
75  virtual void SetAuthMetadataProcessor(
76  const std::shared_ptr<grpc::AuthMetadataProcessor>& processor);
77 
78  protected:
80 
81  grpc_server_credentials* c_creds() const { return c_creds_; }
82 
83  private:
84  // Needed for access to AddPortToServer.
85  friend class Server;
86  // Needed for access to c_creds_.
87  friend class ServerBuilder;
88  friend std::shared_ptr<ServerCredentials> grpc::XdsServerCredentials(
89  const std::shared_ptr<ServerCredentials>& fallback_credentials);
90 
95  // TODO(dgq): the "port" part seems to be a misnomer.
96  virtual int AddPortToServer(const std::string& addr, grpc_server* server);
97 
98  grpc_server_credentials* c_creds_;
99 };
100 
102 std::shared_ptr<ServerCredentials> SslServerCredentials(
103  const grpc::SslServerCredentialsOptions& options);
104 
105 std::shared_ptr<ServerCredentials> InsecureServerCredentials();
106 
107 namespace experimental {
108 
112 };
113 
115 std::shared_ptr<ServerCredentials> AltsServerCredentials(
116  const AltsServerCredentialsOptions& options);
117 
119 std::shared_ptr<ServerCredentials> LocalServerCredentials(
121 
123 std::shared_ptr<ServerCredentials> TlsServerCredentials(
125 
126 } // namespace experimental
127 } // namespace grpc
128 
129 #endif // GRPCPP_SECURITY_SERVER_CREDENTIALS_H
grpc::InsecureServerCredentials
std::shared_ptr< ServerCredentials > InsecureServerCredentials()
tls_credentials_options.h
grpc::ServerCredentials::c_creds
grpc_server_credentials * c_creds() const
Definition: server_credentials.h:81
grpc::SslServerCredentials
std::shared_ptr< ServerCredentials > SslServerCredentials(const grpc::SslServerCredentialsOptions &options)
Builds SSL ServerCredentials given SSL specific options.
grpc::SslServerCredentialsOptions::PemKeyCertPair
Definition: server_credentials.h:48
grpc::Server
Represents a gRPC server.
Definition: server.h:57
grpc
An Alarm posts the user-provided tag to its associated completion queue or invokes the user-provided ...
Definition: alarm.h:33
grpc::SslServerCredentialsOptions::force_client_auth
bool force_client_auth
Definition: server_credentials.h:55
grpc::ServerCredentials
Wrapper around grpc_server_credentials, a way to authenticate a server.
Definition: server_credentials.h:69
grpc::experimental::AltsServerCredentials
std::shared_ptr< ServerCredentials > AltsServerCredentials(const AltsServerCredentialsOptions &options)
Builds ALTS ServerCredentials given ALTS specific options.
grpc::XdsServerCredentials
std::shared_ptr< ServerCredentials > XdsServerCredentials(const std::shared_ptr< ServerCredentials > &fallback_credentials)
Builds Xds ServerCredentials given fallback credentials.
grpc::SslServerCredentialsOptions::PemKeyCertPair::private_key
std::string private_key
Definition: server_credentials.h:49
grpc::experimental::LocalServerCredentials
std::shared_ptr< ServerCredentials > LocalServerCredentials(grpc_local_connect_type type)
Builds Local ServerCredentials.
auth_metadata_processor.h
grpc_server
struct grpc_server grpc_server
A server listens to some port and responds to request calls.
Definition: grpc_types.h:64
grpc_ssl_client_certificate_request_type
grpc_ssl_client_certificate_request_type
Definition: grpc_security_constants.h:79
grpc::SslServerCredentialsOptions::SslServerCredentialsOptions
SslServerCredentialsOptions()
Definition: server_credentials.h:41
grpc::SslServerCredentialsOptions
Options to create ServerCredentials with SSL.
Definition: server_credentials.h:39
grpc::SslServerCredentialsOptions::PemKeyCertPair::cert_chain
std::string cert_chain
Definition: server_credentials.h:50
grpc::SslServerCredentialsOptions::SslServerCredentialsOptions
SslServerCredentialsOptions(grpc_ssl_client_certificate_request_type request_type)
Definition: server_credentials.h:44
grpc::ServerCredentials::SetAuthMetadataProcessor
virtual void SetAuthMetadataProcessor(const std::shared_ptr< grpc::AuthMetadataProcessor > &processor)
This method is not thread-safe and has to be called before the server is started.
grpc::internal::GrpcLibrary
Classes that require gRPC to be initialized should inherit from this class.
Definition: grpc_library.h:32
grpc::ServerCredentials::ServerCredentials
ServerCredentials(grpc_server_credentials *creds)
grpc::SslServerCredentialsOptions::pem_root_certs
std::string pem_root_certs
Definition: server_credentials.h:52
grpc::experimental::TlsServerCredentialsOptions
Definition: tls_credentials_options.h:166
grpc_library.h
config.h
GRPC_SSL_DONT_REQUEST_CLIENT_CERTIFICATE
@ GRPC_SSL_DONT_REQUEST_CLIENT_CERTIFICATE
Server does not request client certificate.
Definition: grpc_security_constants.h:84
grpc::SslServerCredentialsOptions::pem_key_cert_pairs
std::vector< PemKeyCertPair > pem_key_cert_pairs
Definition: server_credentials.h:53
grpc_security_constants.h
grpc::SslServerCredentialsOptions::client_certificate_request
grpc_ssl_client_certificate_request_type client_certificate_request
If both force_client_auth and client_certificate_request fields are set, force_client_auth takes effe...
Definition: server_credentials.h:61
grpc::ServerBuilder
A builder class for the creation and startup of grpc::Server instances.
Definition: server_builder.h:88
grpc_server_credentials
struct grpc_server_credentials grpc_server_credentials
— grpc_server_credentials object.
Definition: grpc.h:299
grpc::experimental::AltsServerCredentialsOptions
Options to create ServerCredentials with ALTS.
Definition: server_credentials.h:110
grpc_local_connect_type
grpc_local_connect_type
Type of local connections for which local channel/server credentials will be applied.
Definition: grpc_security_constants.h:143
grpc::ServerCredentials::~ServerCredentials
~ServerCredentials() override
grpc::experimental::TlsServerCredentials
std::shared_ptr< ServerCredentials > TlsServerCredentials(const experimental::TlsServerCredentialsOptions &options)
Builds TLS ServerCredentials given TLS options.