• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_SRC_CORE_LIB_SECURITY_CREDENTIALS_TLS_TLS_CREDENTIALS_H
20 #define GRPC_SRC_CORE_LIB_SECURITY_CREDENTIALS_TLS_TLS_CREDENTIALS_H
21 
22 #include <grpc/credentials.h>
23 #include <grpc/grpc.h>
24 #include <grpc/grpc_security.h>
25 #include <grpc/support/port_platform.h>
26 
27 #include "src/core/lib/channel/channel_args.h"
28 #include "src/core/lib/security/credentials/credentials.h"
29 #include "src/core/lib/security/security_connector/security_connector.h"
30 #include "src/core/util/ref_counted_ptr.h"
31 #include "src/core/util/unique_type_name.h"
32 
33 class TlsCredentials final : public grpc_channel_credentials {
34  public:
35   explicit TlsCredentials(
36       grpc_core::RefCountedPtr<grpc_tls_credentials_options> options);
37   ~TlsCredentials() override;
38 
39   grpc_core::RefCountedPtr<grpc_channel_security_connector>
40   create_security_connector(
41       grpc_core::RefCountedPtr<grpc_call_credentials> call_creds,
42       const char* target_name, grpc_core::ChannelArgs* args) override;
43 
44   static grpc_core::UniqueTypeName Type();
45 
type()46   grpc_core::UniqueTypeName type() const override { return Type(); }
47 
options()48   grpc_tls_credentials_options* options() const { return options_.get(); }
49 
50  private:
51   int cmp_impl(const grpc_channel_credentials* other) const override;
52 
53   grpc_core::RefCountedPtr<grpc_tls_credentials_options> options_;
54 };
55 
56 class TlsServerCredentials final : public grpc_server_credentials {
57  public:
58   explicit TlsServerCredentials(
59       grpc_core::RefCountedPtr<grpc_tls_credentials_options> options);
60   ~TlsServerCredentials() override;
61 
62   grpc_core::RefCountedPtr<grpc_server_security_connector>
63   create_security_connector(const grpc_core::ChannelArgs& /* args */) override;
64 
65   static grpc_core::UniqueTypeName Type();
66 
type()67   grpc_core::UniqueTypeName type() const override { return Type(); }
68 
options()69   grpc_tls_credentials_options* options() const { return options_.get(); }
70 
71  private:
72   grpc_core::RefCountedPtr<grpc_tls_credentials_options> options_;
73 };
74 
75 #endif  // GRPC_SRC_CORE_LIB_SECURITY_CREDENTIALS_TLS_TLS_CREDENTIALS_H
76