Built motion from commit 6a09e18b.|2.6.11
[motion2.git] / legacy-libs / grpc-cloned / deps / grpc / src / core / lib / security / security_connector / ssl / ssl_security_connector.h
1 /*
2  *
3  * Copyright 2018 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 GRPC_CORE_LIB_SECURITY_SECURITY_CONNECTOR_SSL_SSL_SECURITY_CONNECTOR_H
20 #define GRPC_CORE_LIB_SECURITY_SECURITY_CONNECTOR_SSL_SSL_SECURITY_CONNECTOR_H
21
22 #include <grpc/support/port_platform.h>
23
24 #include <grpc/grpc_security.h>
25
26 #include "src/core/lib/security/security_connector/security_connector.h"
27
28 #include "src/core/lib/gprpp/ref_counted_ptr.h"
29 #include "src/core/tsi/ssl_transport_security.h"
30 #include "src/core/tsi/transport_security_interface.h"
31
32 typedef struct {
33   tsi_ssl_pem_key_cert_pair* pem_key_cert_pair;
34   char* pem_root_certs;
35   verify_peer_options verify_options;
36 } grpc_ssl_config;
37
38 /* Creates an SSL channel_security_connector.
39    - request_metadata_creds is the credentials object which metadata
40      will be sent with each request. This parameter can be NULL.
41    - config is the SSL config to be used for the SSL channel establishment.
42    - is_client should be 0 for a server or a non-0 value for a client.
43    - secure_peer_name is the secure peer name that should be checked in
44      grpc_channel_security_connector_check_peer. This parameter may be NULL in
45      which case the peer name will not be checked. Note that if this parameter
46      is not NULL, then, pem_root_certs should not be NULL either.
47    - sc is a pointer on the connector to be created.
48   This function returns GRPC_SECURITY_OK in case of success or a
49   specific error code otherwise.
50 */
51 grpc_core::RefCountedPtr<grpc_channel_security_connector>
52 grpc_ssl_channel_security_connector_create(
53     grpc_core::RefCountedPtr<grpc_channel_credentials> channel_creds,
54     grpc_core::RefCountedPtr<grpc_call_credentials> request_metadata_creds,
55     const grpc_ssl_config* config, const char* target_name,
56     const char* overridden_target_name,
57     tsi_ssl_session_cache* ssl_session_cache);
58
59 /* Config for ssl servers. */
60 typedef struct {
61   tsi_ssl_pem_key_cert_pair* pem_key_cert_pairs = nullptr;
62   size_t num_key_cert_pairs = 0;
63   char* pem_root_certs = nullptr;
64   grpc_ssl_client_certificate_request_type client_certificate_request =
65       GRPC_SSL_DONT_REQUEST_CLIENT_CERTIFICATE;
66 } grpc_ssl_server_config;
67
68 /* Creates an SSL server_security_connector.
69    - config is the SSL config to be used for the SSL channel establishment.
70    - sc is a pointer on the connector to be created.
71   This function returns GRPC_SECURITY_OK in case of success or a
72   specific error code otherwise.
73 */
74 grpc_core::RefCountedPtr<grpc_server_security_connector>
75 grpc_ssl_server_security_connector_create(
76     grpc_core::RefCountedPtr<grpc_server_credentials> server_credentials);
77
78 #endif /* GRPC_CORE_LIB_SECURITY_SECURITY_CONNECTOR_SSL_SSL_SECURITY_CONNECTOR_H \
79         */