Go to the documentation of this file.
21 #include "absl/flags/flag.h"
30 "Replaced by --channel_creds_type=ssl.");
32 "Replaced by --channel_creds_type=gdc.");
34 "Replaced by --call_creds=access_token=<token>.");
37 "If not empty, treat the server host name as this for ssl/tls certificate "
41 "If not empty, load this PEM formatted client certificate file. Requires "
42 "use of --ssl_client_key.");
44 "If not empty, load this PEM formatted private key. Requires use of "
48 "The type of local connections for which local channel credentials will "
49 "be applied. Should be local_tcp or uds.");
52 "The channel creds type: insecure, ssl, gdc (Google Default Credentials), "
56 "Call credentials to use: none (default), or access_token=<token>. If "
57 "provided, the call creds are composited on top of channel creds.");
64 const char ACCESS_TOKEN_PREFIX[] =
"access_token=";
65 constexpr
int ACCESS_TOKEN_PREFIX_LEN =
66 sizeof(ACCESS_TOKEN_PREFIX) /
sizeof(*ACCESS_TOKEN_PREFIX) - 1;
69 return auth.length() > ACCESS_TOKEN_PREFIX_LEN &&
70 auth.compare(0, ACCESS_TOKEN_PREFIX_LEN, ACCESS_TOKEN_PREFIX) == 0;
74 if (!IsAccessToken(auth)) {
88 std::shared_ptr<grpc::ChannelCredentials>
92 }
else if (
absl::GetFlag(FLAGS_channel_creds_type) ==
"ssl") {
116 }
else if (
absl::GetFlag(FLAGS_channel_creds_type) ==
"gdc") {
118 }
else if (
absl::GetFlag(FLAGS_channel_creds_type) ==
"alts") {
121 }
else if (
absl::GetFlag(FLAGS_channel_creds_type) ==
"local") {
122 if (
absl::GetFlag(FLAGS_local_connect_type) ==
"local_tcp") {
124 }
else if (
absl::GetFlag(FLAGS_local_connect_type) ==
"uds") {
128 "--local_connect_type=%s invalid; must be local_tcp or uds.\n",
133 "--channel_creds_type=%s invalid; must be insecure, ssl, gdc, "
136 return std::shared_ptr<grpc::ChannelCredentials>();
147 return std::shared_ptr<grpc::CallCredentials>();
150 "--call_creds=%s invalid; must be none "
151 "or access_token=<token>.\n",
153 return std::shared_ptr<grpc::CallCredentials>();
164 std::shared_ptr<grpc::ChannelCredentials> channel_creds =
168 return (channel_creds ==
nullptr ||
call_creds ==
nullptr)
174 return " --ssl_target ; Set server host for ssl validation\n"
175 " --ssl_client_cert ; Client cert for ssl\n"
176 " --ssl_client_key ; Client private key for ssl\n"
177 " --local_connect_type ; Set to local_tcp or uds\n"
178 " --channel_creds_type ; Set to insecure, ssl, gdc, alts, or "
180 " --call_creds ; Set to none, or"
181 " access_token=<token>\n";
185 bool use_ssl =
absl::GetFlag(FLAGS_channel_creds_type) ==
"ssl" ||
GPRAPI void grpc_slice_unref(grpc_slice s)
void SetFlag(absl::Flag< T > *flag, const T &v)
grpc_error_handle grpc_load_file(const char *filename, int add_null_terminator, grpc_slice *output)
std::shared_ptr< grpc::ChannelCredentials > GetCredentials() const
std::shared_ptr< ChannelCredentials > SslCredentials(const SslCredentialsOptions &options)
Builds SSL Credentials given SSL specific options.
virtual std::string GetDefaultChannelCredsType() const
virtual std::shared_ptr< grpc::CallCredentials > GetCallCredentials() const
ABSL_FLAG(std::string, ssl_target, "", "If not empty, treat the server host name as this for ssl/tls certificate " "validation.")
grpc::string pem_cert_chain
std::shared_ptr< ChannelCredentials > CompositeChannelCredentials(const std::shared_ptr< ChannelCredentials > &channel_creds, const std::shared_ptr< CallCredentials > &call_creds)
#define GRPC_LOG_IF_ERROR(what, error)
std::shared_ptr< ChannelCredentials > GoogleDefaultCredentials()
Options used to build SslCredentials.
def c_str(s, encoding='ascii')
std::shared_ptr< ChannelCredentials > LocalCredentials(grpc_local_connect_type type)
Builds Local Credentials.
ABSL_RETIRED_FLAG(bool, enable_ssl, false, "Replaced by --channel_creds_type=ssl.")
virtual std::string GetDefaultCallCreds() const
virtual std::string GetCredentialUsage() const
void call_creds(grpc_end2end_test_config config)
GPRAPI grpc_slice grpc_empty_slice(void)
ABSL_MUST_USE_RESULT T GetFlag(const absl::Flag< T > &flag)
grpc::string pem_private_key
virtual std::string GetSslTargetNameOverride() const
virtual std::shared_ptr< grpc::ChannelCredentials > GetChannelCredentials() const
std::shared_ptr< ChannelCredentials > AltsCredentials(const AltsCredentialsOptions &options)
Builds ALTS Credentials given ALTS specific options.
std::shared_ptr< CallCredentials > AccessTokenCredentials(const grpc::string &access_token)
std::shared_ptr< ChannelCredentials > InsecureChannelCredentials()
Credentials for an unencrypted, unauthenticated channel.
Options used to build AltsCredentials.
std::string StringFromCopiedSlice(grpc_slice slice)
grpc
Author(s):
autogenerated on Thu Mar 13 2025 02:58:46