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 28 #include <iostream> 29 #include <string> 30 #include <memory> 31 32 #include "utils/log_adapter.h" 33 #include "ps/core/comm_util.h" 34 #include "ps/constants.h" 35 #include "ps/core/file_configuration.h" 36 37 namespace mindspore { 38 namespace ps { 39 namespace core { 40 class SSLHTTP { 41 public: GetInstance()42 static SSLHTTP &GetInstance() { 43 static SSLHTTP instance; 44 return instance; 45 } 46 SSL_CTX *GetSSLCtx() const; 47 48 private: 49 SSLHTTP(); 50 virtual ~SSLHTTP(); 51 SSLHTTP(const SSLHTTP &) = delete; 52 SSLHTTP &operator=(const SSLHTTP &) = delete; 53 54 void InitSSL(); 55 void CleanSSL(); 56 57 SSL_CTX *ssl_ctx_; 58 }; 59 } // namespace core 60 } // namespace ps 61 } // namespace mindspore 62 #endif // MINDSPORE_CCSRC_PS_CORE_COMMUNICATOR_SSL_HTTP_H_ 63