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/support/port_platform.h>
23 
24 #include <grpc/grpc.h>
25 #include <grpc/grpc_security.h>
26 
27 #include "src/core/lib/channel/channel_args.h"
28 #include "src/core/lib/gprpp/ref_counted_ptr.h"
29 #include "src/core/lib/gprpp/unique_type_name.h"
30 #include "src/core/lib/security/credentials/credentials.h"
31 #include "src/core/lib/security/security_connector/security_connector.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   grpc_core::UniqueTypeName type() const override;
45 
options()46   grpc_tls_credentials_options* options() const { return options_.get(); }
47 
48  private:
49   int cmp_impl(const grpc_channel_credentials* other) const override;
50 
51   grpc_core::RefCountedPtr<grpc_tls_credentials_options> options_;
52 };
53 
54 class TlsServerCredentials final : public grpc_server_credentials {
55  public:
56   explicit TlsServerCredentials(
57       grpc_core::RefCountedPtr<grpc_tls_credentials_options> options);
58   ~TlsServerCredentials() override;
59 
60   grpc_core::RefCountedPtr<grpc_server_security_connector>
61   create_security_connector(const grpc_core::ChannelArgs& /* args */) override;
62 
63   grpc_core::UniqueTypeName type() const override;
64 
options()65   grpc_tls_credentials_options* options() const { return options_.get(); }
66 
67  private:
68   grpc_core::RefCountedPtr<grpc_tls_credentials_options> options_;
69 };
70 
71 #endif  // GRPC_SRC_CORE_LIB_SECURITY_CREDENTIALS_TLS_TLS_CREDENTIALS_H
72