1 /** 2 * Copyright 2021 Huawei Technologies Co., Ltd 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef MINDSPORE_CCSRC_PS_CORE_COMMUNICATOR_SSL_HTTP_H_ 18 #define MINDSPORE_CCSRC_PS_CORE_COMMUNICATOR_SSL_HTTP_H_ 19 20 #include <openssl/ssl.h> 21 #include <openssl/rand.h> 22 #include <openssl/err.h> 23 #include <openssl/evp.h> 24 #include <assert.h> 25 #include <openssl/pkcs12.h> 26 #include <openssl/bio.h> 27 #include <iostream> 28 #include <string> 29 #include <memory> 30 #include "utils/log_adapter.h" 31 #include "ps/core/comm_util.h" 32 #include "include/backend/distributed/ps/constants.h" 33 #include "ps/core/file_configuration.h" 34 35 namespace mindspore { 36 namespace ps { 37 namespace core { 38 class SSLHTTP { 39 public: GetInstance()40 static SSLHTTP &GetInstance() { 41 static SSLHTTP instance; 42 return instance; 43 } 44 SSL_CTX *GetSSLCtx() const; 45 46 private: 47 SSLHTTP(); 48 virtual ~SSLHTTP(); 49 SSLHTTP(const SSLHTTP &) = delete; 50 SSLHTTP &operator=(const SSLHTTP &) = delete; 51 52 void InitSSL(); 53 void CleanSSL(); 54 void InitSSLCtx(const X509 *cert, const EVP_PKEY *pkey, const std::string &default_cipher_list); 55 SSL_CTX *ssl_ctx_; 56 }; 57 } // namespace core 58 } // namespace ps 59 } // namespace mindspore 60 #endif // MINDSPORE_CCSRC_PS_CORE_COMMUNICATOR_SSL_HTTP_H_ 61