• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2025 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #ifdef HDC_SUPPORT_ENCRYPT_TCP
16 #include "daemon_ssl.h"
17 namespace Hdc {
HdcDaemonSSL(SSLInfoPtr hSSLInfo)18 HdcDaemonSSL::HdcDaemonSSL(SSLInfoPtr hSSLInfo) : HdcSSLBase(hSSLInfo)
19 {
20 }
21 
~HdcDaemonSSL()22 HdcDaemonSSL::~HdcDaemonSSL()
23 {
24     WRITE_LOG(LOG_DEBUG, "~HdcDaemonSSL");
25 }
26 
SetSSLMethod()27 const SSL_METHOD *HdcDaemonSSL::SetSSLMethod()
28 {
29     return TLS_server_method();
30 }
31 
SetPskCallback()32 bool HdcDaemonSSL::SetPskCallback()
33 {
34     if (SSL_CTX_set_ex_data(sslCtx, 0, preSharedKey) != 1) {
35         return false;
36     }
37     SSL_CTX_set_psk_server_callback(sslCtx, PskServerCallback);
38     return true;
39 }
40 
SetSSLState()41 void HdcDaemonSSL::SetSSLState()
42 {
43     SSL_set_accept_state(ssl);
44 }
45 } // namespace Hdc
46 #endif // HDC_SUPPORT_ENCRYPT_TCP