chromium/third_party/grpc/src/src/core/lib/security/security_connector/ssl_utils.cc

//
//
// Copyright 2015 gRPC authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//

#include <grpc/support/port_platform.h>

#include "src/core/lib/security/security_connector/ssl_utils.h"

#include <stdint.h>
#include <string.h>

#include <vector>

#include "absl/strings/match.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/str_split.h"

#include <grpc/grpc.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/sync.h>

#include "src/core/ext/transport/chttp2/alpn/alpn.h"
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/gpr/useful.h"
#include "src/core/lib/gprpp/global_config.h"
#include "src/core/lib/gprpp/host_port.h"
#include "src/core/lib/gprpp/memory.h"
#include "src/core/lib/gprpp/ref_counted_ptr.h"
#include "src/core/lib/iomgr/load_file.h"
#include "src/core/lib/security/context/security_context.h"
#include "src/core/lib/security/security_connector/load_system_roots.h"
#include "src/core/lib/security/security_connector/ssl_utils_config.h"
#include "src/core/tsi/ssl_transport_security.h"
#include "src/core/tsi/transport_security.h"

// -- Constants. --

#if defined(GRPC_ROOT_PEM_PATH)
static const char* installed_roots_path = GRPC_ROOT_PEM_PATH;
#elif defined(INSTALL_PREFIX)
static const char* installed_roots_path =
    INSTALL_PREFIX "/usr/share/grpc/roots.pem";
#else
static const char* installed_roots_path =;
#endif

#ifndef TSI_OPENSSL_ALPN_SUPPORT
#define TSI_OPENSSL_ALPN_SUPPORT
#endif

// -- Overridden default roots. --

static grpc_ssl_roots_override_callback ssl_roots_override_cb =;

void grpc_set_ssl_roots_override_callback(grpc_ssl_roots_override_callback cb) {}

// -- Cipher suites. --

static gpr_once cipher_suites_once =;
static const char* cipher_suites =;

// All cipher suites for default are compliant with HTTP2.
GPR_GLOBAL_CONFIG_DEFINE_STRING()

static void init_cipher_suites(void) {}

// --- Util ---

const char* grpc_get_ssl_cipher_suites(void) {}

tsi_client_certificate_request_type
grpc_get_tsi_client_certificate_request_type(
    grpc_ssl_client_certificate_request_type grpc_request_type) {}

tsi_tls_version grpc_get_tsi_tls_version(grpc_tls_version tls_version) {}

grpc_error_handle grpc_ssl_check_alpn(const tsi_peer* peer) {}

grpc_error_handle grpc_ssl_check_peer_name(absl::string_view peer_name,
                                           const tsi_peer* peer) {}

void grpc_tsi_ssl_pem_key_cert_pairs_destroy(tsi_ssl_pem_key_cert_pair* kp,
                                             size_t num_key_cert_pairs) {}

namespace grpc_core {

absl::Status SslCheckCallHost(absl::string_view host,
                              absl::string_view target_name,
                              absl::string_view overridden_target_name,
                              grpc_auth_context* auth_context) {}

}  // namespace grpc_core

const char** grpc_fill_alpn_protocol_strings(size_t* num_alpn_protocols) {}

int grpc_ssl_host_matches_name(const tsi_peer* peer,
                               absl::string_view peer_name) {}

int grpc_ssl_cmp_target_name(absl::string_view target_name,
                             absl::string_view other_target_name,
                             absl::string_view overridden_target_name,
                             absl::string_view other_overridden_target_name) {}

static bool IsSpiffeId(absl::string_view uri) {}

grpc_core::RefCountedPtr<grpc_auth_context> grpc_ssl_peer_to_auth_context(
    const tsi_peer* peer, const char* transport_security_type) {}

static void add_shallow_auth_property_to_peer(tsi_peer* peer,
                                              const grpc_auth_property* prop,
                                              const char* tsi_prop_name) {}

tsi_peer grpc_shallow_peer_from_ssl_auth_context(
    const grpc_auth_context* auth_context) {}

void grpc_shallow_peer_destruct(tsi_peer* peer) {}

grpc_security_status grpc_ssl_tsi_client_handshaker_factory_init(
    tsi_ssl_pem_key_cert_pair* pem_key_cert_pair, const char* pem_root_certs,
    bool skip_server_certificate_verification, tsi_tls_version min_tls_version,
    tsi_tls_version max_tls_version, tsi_ssl_session_cache* ssl_session_cache,
    tsi::TlsSessionKeyLoggerCache::TlsSessionKeyLogger* tls_session_key_logger,
    const char* crl_directory,
    tsi_ssl_client_handshaker_factory** handshaker_factory) {}

grpc_security_status grpc_ssl_tsi_server_handshaker_factory_init(
    tsi_ssl_pem_key_cert_pair* pem_key_cert_pairs, size_t num_key_cert_pairs,
    const char* pem_root_certs,
    grpc_ssl_client_certificate_request_type client_certificate_request,
    tsi_tls_version min_tls_version, tsi_tls_version max_tls_version,
    tsi::TlsSessionKeyLoggerCache::TlsSessionKeyLogger* tls_session_key_logger,
    const char* crl_directory,
    tsi_ssl_server_handshaker_factory** handshaker_factory) {}

// --- Ssl cache implementation. ---

grpc_ssl_session_cache* grpc_ssl_session_cache_create_lru(size_t capacity) {}

void grpc_ssl_session_cache_destroy(grpc_ssl_session_cache* cache) {}

static void* grpc_ssl_session_cache_arg_copy(void* p) {}

static void grpc_ssl_session_cache_arg_destroy(void* p) {}

static int grpc_ssl_session_cache_arg_cmp(void* p, void* q) {}

grpc_arg grpc_ssl_session_cache_create_channel_arg(
    grpc_ssl_session_cache* cache) {}

// --- Default SSL root store implementation. ---

namespace grpc_core {

tsi_ssl_root_certs_store* DefaultSslRootStore::default_root_store_;
grpc_slice DefaultSslRootStore::default_pem_root_certs_;

const tsi_ssl_root_certs_store* DefaultSslRootStore::GetRootStore() {}

const char* DefaultSslRootStore::GetPemRootCerts() {}

grpc_slice DefaultSslRootStore::ComputePemRootCerts() {}

void DefaultSslRootStore::InitRootStore() {}

void DefaultSslRootStore::InitRootStoreOnce() {}

}  // namespace grpc_core