blob: 60e167eb8855fa7fed5ac3b467d2e374797918a6 [file] [log] [blame]
Deepak Lukosedba4c5f2016-03-25 12:54:25 -07001/*
2 *
Jan Tattermusch7897ae92017-06-07 22:57:36 +02003 * Copyright 2016 gRPC authors.
Deepak Lukosedba4c5f2016-03-25 12:54:25 -07004 *
Jan Tattermusch7897ae92017-06-07 22:57:36 +02005 * 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
Deepak Lukosedba4c5f2016-03-25 12:54:25 -07008 *
Jan Tattermusch7897ae92017-06-07 22:57:36 +02009 * http://www.apache.org/licenses/LICENSE-2.0
Deepak Lukosedba4c5f2016-03-25 12:54:25 -070010 *
Jan Tattermusch7897ae92017-06-07 22:57:36 +020011 * 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.
Deepak Lukosedba4c5f2016-03-25 12:54:25 -070016 *
17 */
18
19#ifndef GRPC_GRPC_SECURITY_CONSTANTS_H
20#define GRPC_GRPC_SECURITY_CONSTANTS_H
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
26#define GRPC_TRANSPORT_SECURITY_TYPE_PROPERTY_NAME "transport_security_type"
27#define GRPC_SSL_TRANSPORT_SECURITY_TYPE "ssl"
28
29#define GRPC_X509_CN_PROPERTY_NAME "x509_common_name"
30#define GRPC_X509_SAN_PROPERTY_NAME "x509_subject_alternative_name"
31#define GRPC_X509_PEM_CERT_PROPERTY_NAME "x509_pem_cert"
32
Alexander Polcynd809a152017-05-03 14:49:41 -070033/** Environment variable that points to the default SSL roots file. This file
Deepak Lukosedba4c5f2016-03-25 12:54:25 -070034 must be a PEM encoded file with all the roots such as the one that can be
35 downloaded from https://pki.google.com/roots.pem. */
36#define GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR \
37 "GRPC_DEFAULT_SSL_ROOTS_FILE_PATH"
38
Alexander Polcynd809a152017-05-03 14:49:41 -070039/** Environment variable that points to the google default application
Deepak Lukosedba4c5f2016-03-25 12:54:25 -070040 credentials json key or refresh token. Used in the
41 grpc_google_default_credentials_create function. */
42#define GRPC_GOOGLE_CREDENTIALS_ENV_VAR "GOOGLE_APPLICATION_CREDENTIALS"
43
Alexander Polcynd809a152017-05-03 14:49:41 -070044/** Results for the SSL roots override callback. */
Deepak Lukosedba4c5f2016-03-25 12:54:25 -070045typedef enum {
46 GRPC_SSL_ROOTS_OVERRIDE_OK,
Alexander Polcynd809a152017-05-03 14:49:41 -070047 GRPC_SSL_ROOTS_OVERRIDE_FAIL_PERMANENTLY, /** Do not try fallback options. */
Deepak Lukosedba4c5f2016-03-25 12:54:25 -070048 GRPC_SSL_ROOTS_OVERRIDE_FAIL
49} grpc_ssl_roots_override_result;
50
Justin Burkec1d354d2017-09-19 15:06:01 -070051/** Callback results for dynamically loading a SSL certificate config. */
52typedef enum {
53 GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_UNCHANGED,
54 GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_NEW,
55 GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_FAIL
56} grpc_ssl_certificate_config_reload_status;
57
Deepak Lukosedba4c5f2016-03-25 12:54:25 -070058typedef enum {
Alexander Polcynd809a152017-05-03 14:49:41 -070059 /** Server does not request client certificate. A client can present a self
Deepak Lukosedba4c5f2016-03-25 12:54:25 -070060 signed or signed certificates if it wishes to do so and they would be
61 accepted. */
62 GRPC_SSL_DONT_REQUEST_CLIENT_CERTIFICATE,
Alexander Polcynd809a152017-05-03 14:49:41 -070063 /** Server requests client certificate but does not enforce that the client
Deepak Lukosedba4c5f2016-03-25 12:54:25 -070064 presents a certificate.
65
66 If the client presents a certificate, the client authentication is left to
67 the application based on the metadata like certificate etc.
68
69 The key cert pair should still be valid for the SSL connection to be
70 established. */
71 GRPC_SSL_REQUEST_CLIENT_CERTIFICATE_BUT_DONT_VERIFY,
Alexander Polcynd809a152017-05-03 14:49:41 -070072 /** Server requests client certificate but does not enforce that the client
Deepak Lukosedba4c5f2016-03-25 12:54:25 -070073 presents a certificate.
74
75 If the client presents a certificate, the client authentication is done by
76 grpc framework (The client needs to either present a signed cert or skip no
77 certificate for a successful connection).
78
79 The key cert pair should still be valid for the SSL connection to be
80 established. */
81 GRPC_SSL_REQUEST_CLIENT_CERTIFICATE_AND_VERIFY,
Alexander Polcynd809a152017-05-03 14:49:41 -070082 /** Server requests client certificate but enforces that the client presents a
Deepak Lukosedba4c5f2016-03-25 12:54:25 -070083 certificate.
84
85 If the client presents a certificate, the client authentication is left to
86 the application based on the metadata like certificate etc.
87
88 The key cert pair should still be valid for the SSL connection to be
89 established. */
90 GRPC_SSL_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_BUT_DONT_VERIFY,
Alexander Polcynd809a152017-05-03 14:49:41 -070091 /** Server requests client certificate but enforces that the client presents a
Deepak Lukosedba4c5f2016-03-25 12:54:25 -070092 certificate.
93
94 The cerificate presented by the client is verified by grpc framework (The
95 client needs to present signed certs for a successful connection).
96
97 The key cert pair should still be valid for the SSL connection to be
98 established. */
99 GRPC_SSL_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY
100} grpc_ssl_client_certificate_request_type;
101
102#ifdef __cplusplus
103}
104#endif
105
106#endif /* GRPC_GRPC_SECURITY_CONSTANTS_H */