| 1654 | }; |
| 1655 | |
| 1656 | class SSLClient : public ClientImpl { |
| 1657 | public: |
| 1658 | explicit SSLClient(const std::string &host); |
| 1659 | |
| 1660 | explicit SSLClient(const std::string &host, int port); |
| 1661 | |
| 1662 | explicit SSLClient(const std::string &host, int port, |
| 1663 | const std::string &client_cert_path, |
| 1664 | const std::string &client_key_path); |
| 1665 | |
| 1666 | explicit SSLClient(const std::string &host, int port, X509 *client_cert, |
| 1667 | EVP_PKEY *client_key); |
| 1668 | |
| 1669 | ~SSLClient() override; |
| 1670 | |
| 1671 | bool is_valid() const override; |
| 1672 | |
| 1673 | void set_ca_cert_store(X509_STORE *ca_cert_store); |
| 1674 | void load_ca_cert_store(const char *ca_cert, std::size_t size); |
| 1675 | |
| 1676 | long get_openssl_verify_result() const; |
| 1677 | |
| 1678 | SSL_CTX *ssl_context() const; |
| 1679 | |
| 1680 | private: |
| 1681 | bool create_and_connect_socket(Socket &socket, Error &error) override; |
| 1682 | void shutdown_ssl(Socket &socket, bool shutdown_gracefully) override; |
| 1683 | void shutdown_ssl_impl(Socket &socket, bool shutdown_socket); |
| 1684 | |
| 1685 | bool process_socket(const Socket &socket, |
| 1686 | std::function<bool(Stream &strm)> callback) override; |
| 1687 | bool is_ssl() const override; |
| 1688 | |
| 1689 | bool connect_with_proxy(Socket &sock, Response &res, bool &success, |
| 1690 | Error &error); |
| 1691 | bool initialize_ssl(Socket &socket, Error &error); |
| 1692 | |
| 1693 | bool load_certs(); |
| 1694 | |
| 1695 | bool verify_host(X509 *server_cert) const; |
| 1696 | bool verify_host_with_subject_alt_name(X509 *server_cert) const; |
| 1697 | bool verify_host_with_common_name(X509 *server_cert) const; |
| 1698 | bool check_host_name(const char *pattern, size_t pattern_len) const; |
| 1699 | |
| 1700 | SSL_CTX *ctx_; |
| 1701 | std::mutex ctx_mutex_; |
| 1702 | std::once_flag initialize_cert_; |
| 1703 | |
| 1704 | std::vector<std::string> host_components_; |
| 1705 | |
| 1706 | long verify_result_ = 0; |
| 1707 | |
| 1708 | friend class ClientImpl; |
| 1709 | }; |
| 1710 | #endif |
| 1711 | |
| 1712 | /* |
nothing calls this directly
no outgoing calls
no test coverage detected