grpc_security_constants.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. *
  3. * Copyright 2016 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. #ifndef GRPC_GRPC_SECURITY_CONSTANTS_H
  19. #define GRPC_GRPC_SECURITY_CONSTANTS_H
  20. #ifdef __cplusplus
  21. extern "C" {
  22. #endif
  23. #define GRPC_TRANSPORT_SECURITY_TYPE_PROPERTY_NAME "transport_security_type"
  24. #define GRPC_SSL_TRANSPORT_SECURITY_TYPE "ssl"
  25. #define GRPC_X509_CN_PROPERTY_NAME "x509_common_name"
  26. #define GRPC_X509_SAN_PROPERTY_NAME "x509_subject_alternative_name"
  27. #define GRPC_X509_PEM_CERT_PROPERTY_NAME "x509_pem_cert"
  28. /** Environment variable that points to the default SSL roots file. This file
  29. must be a PEM encoded file with all the roots such as the one that can be
  30. downloaded from https://pki.google.com/roots.pem. */
  31. #define GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR \
  32. "GRPC_DEFAULT_SSL_ROOTS_FILE_PATH"
  33. /** Environment variable that points to the google default application
  34. credentials json key or refresh token. Used in the
  35. grpc_google_default_credentials_create function. */
  36. #define GRPC_GOOGLE_CREDENTIALS_ENV_VAR "GOOGLE_APPLICATION_CREDENTIALS"
  37. /** Results for the SSL roots override callback. */
  38. typedef enum {
  39. GRPC_SSL_ROOTS_OVERRIDE_OK,
  40. GRPC_SSL_ROOTS_OVERRIDE_FAIL_PERMANENTLY, /** Do not try fallback options. */
  41. GRPC_SSL_ROOTS_OVERRIDE_FAIL
  42. } grpc_ssl_roots_override_result;
  43. typedef enum {
  44. /** Server does not request client certificate. A client can present a self
  45. signed or signed certificates if it wishes to do so and they would be
  46. accepted. */
  47. GRPC_SSL_DONT_REQUEST_CLIENT_CERTIFICATE,
  48. /** Server requests client certificate but does not enforce that the client
  49. presents a certificate.
  50. If the client presents a certificate, the client authentication is left to
  51. the application based on the metadata like certificate etc.
  52. The key cert pair should still be valid for the SSL connection to be
  53. established. */
  54. GRPC_SSL_REQUEST_CLIENT_CERTIFICATE_BUT_DONT_VERIFY,
  55. /** Server requests client certificate but does not enforce that the client
  56. presents a certificate.
  57. If the client presents a certificate, the client authentication is done by
  58. grpc framework (The client needs to either present a signed cert or skip no
  59. certificate for a successful connection).
  60. The key cert pair should still be valid for the SSL connection to be
  61. established. */
  62. GRPC_SSL_REQUEST_CLIENT_CERTIFICATE_AND_VERIFY,
  63. /** Server requests client certificate but enforces that the client presents a
  64. certificate.
  65. If the client presents a certificate, the client authentication is left to
  66. the application based on the metadata like certificate etc.
  67. The key cert pair should still be valid for the SSL connection to be
  68. established. */
  69. GRPC_SSL_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_BUT_DONT_VERIFY,
  70. /** Server requests client certificate but enforces that the client presents a
  71. certificate.
  72. The cerificate presented by the client is verified by grpc framework (The
  73. client needs to present signed certs for a successful connection).
  74. The key cert pair should still be valid for the SSL connection to be
  75. established. */
  76. GRPC_SSL_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY
  77. } grpc_ssl_client_certificate_request_type;
  78. #ifdef __cplusplus
  79. }
  80. #endif
  81. #endif /* GRPC_GRPC_SECURITY_CONSTANTS_H */