#ifndef CC_SSL_H #define CC_SSL_H #include "openssl/ssl.h" #include "CCString.h" #include "Socket/CCClientSocket.h" namespace CTL { class SSL_Client { ssl_st *ssl = nullptr; public: private: public: SSL_Client(ssl_st *ssl); ~SSL_Client(); ByteHander read(char* buffer,size_t size) const; int write(const char* buffer,size_t size) const; SSL* getSSL() const; static bool IsShutDown(const ssl_st *ssl); void release(); bool available() const; }; class SSL_BIO { BIO* r_bio,* w_bio; public: private: public: SSL_BIO(BIO* r_bio,BIO* w_bio); ~SSL_BIO(); }; class CTX_SSL { SSL_CTX* ssl_ctx = nullptr; bool is_Async = false; public: private: public: CTX_SSL(); explicit CTX_SSL(bool Server); ~CTX_SSL(); bool init(bool Server = true); void set_Async(bool flag); bool setSSLCertificate(const CTL::String &CertPath) const; bool setSSLKey(const CTL::String &KeyPath, const CTL::String &Passwd) const; bool setSSLVerify(const CTL::String &CA_Path) const; bool isCTX() const; SSL_Client* createClient(const CTL::Socket* socket) const; SSL_CTX* getSSL_CTX() const; }; class InitSSL_t { public: InitSSL_t(); ~InitSSL_t(); }; } // inline CTL::InitSSL_t InitSSL_ABCDEF_T; #endif