GRPC C++  1.0.0
server_credentials.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2015, Google Inc.
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are
8  * met:
9  *
10  * * Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  * * Redistributions in binary form must reproduce the above
13  * copyright notice, this list of conditions and the following disclaimer
14  * in the documentation and/or other materials provided with the
15  * distribution.
16  * * Neither the name of Google Inc. nor the names of its
17  * contributors may be used to endorse or promote products derived from
18  * this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  *
32  */
33 
34 #ifndef GRPCXX_SECURITY_SERVER_CREDENTIALS_H
35 #define GRPCXX_SECURITY_SERVER_CREDENTIALS_H
36 
37 #include <memory>
38 #include <vector>
39 
41 #include <grpc++/support/config.h>
43 
44 struct grpc_server;
45 
46 namespace grpc {
47 class Server;
48 
49 // Wrapper around \a grpc_server_credentials, a way to authenticate a server.
51  public:
52  virtual ~ServerCredentials();
53 
54  // This method is not thread-safe and has to be called before the server is
55  // started. The last call to this function wins.
56  virtual void SetAuthMetadataProcessor(
57  const std::shared_ptr<AuthMetadataProcessor>& processor) = 0;
58 
59  private:
60  friend class ::grpc::Server;
61 
66  // TODO(dgq): the "port" part seems to be a misnomer.
67  virtual int AddPortToServer(const grpc::string& addr,
68  grpc_server* server) = 0;
69 };
70 
73  // Deprecated
75  : force_client_auth(false),
76  client_certificate_request(GRPC_SSL_DONT_REQUEST_CLIENT_CERTIFICATE) {}
79  : force_client_auth(false), client_certificate_request(request_type) {}
80 
81  struct PemKeyCertPair {
84  };
86  std::vector<PemKeyCertPair> pem_key_cert_pairs;
87  // Deprecated
89 
90  // If both force_client_auth and client_certificate_request fields are set,
91  // force_client_auth takes effect i.e
92  // REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY will be enforced.
94 };
95 
97 std::shared_ptr<ServerCredentials> SslServerCredentials(
98  const SslServerCredentialsOptions& options);
99 
101 std::shared_ptr<ServerCredentials> InsecureServerCredentials();
102 
103 } // namespace grpc
104 
105 #endif // GRPCXX_SECURITY_SERVER_CREDENTIALS_H
grpc::string cert_chain
Definition: server_credentials.h:83
std::shared_ptr< ServerCredentials > InsecureServerCredentials()
Builds insecure server credentials.
std::string string
Definition: config.h:118
Definition: server_credentials.h:81
struct grpc_server grpc_server
A server listens to some port and responds to request calls.
Definition: grpc_types.h:57
bool force_client_auth
Definition: server_credentials.h:88
Definition: server_credentials.h:50
std::vector< PemKeyCertPair > pem_key_cert_pairs
Definition: server_credentials.h:86
SslServerCredentialsOptions(grpc_ssl_client_certificate_request_type request_type)
Definition: server_credentials.h:77
Definition: alarm.h:48
grpc::string pem_root_certs
Definition: server_credentials.h:85
grpc_ssl_client_certificate_request_type
Definition: grpc_security_constants.h:66
virtual void SetAuthMetadataProcessor(const std::shared_ptr< AuthMetadataProcessor > &processor)=0
Options to create ServerCredentials with SSL.
Definition: server_credentials.h:72
grpc_ssl_client_certificate_request_type client_certificate_request
Definition: server_credentials.h:93
std::shared_ptr< ServerCredentials > SslServerCredentials(const SslServerCredentialsOptions &options)
Builds SSL ServerCredentials given SSL specific options.
grpc::string private_key
Definition: server_credentials.h:82
SslServerCredentialsOptions()
Definition: server_credentials.h:74
Definition: grpc_security_constants.h:70