return (ssl_ != nullptr) ? SSL_get_cipher_name(ssl_) : nullptr;
}
+/* static */
+const char* AsyncSSLSocket::getSSLServerNameFromSSL(SSL* ssl) {
+ if (ssl == nullptr) {
+ return nullptr;
+ }
+#ifdef SSL_CTRL_SET_TLSEXT_SERVERNAME_CB
+ return SSL_get_servername(ssl, TLSEXT_NAMETYPE_host_name);
+#else
+ return nullptr;
+#endif
+}
+
const char *AsyncSSLSocket::getSSLServerName() const {
#ifdef SSL_CTRL_SET_TLSEXT_SERVERNAME_CB
- return (ssl_ != nullptr) ? SSL_get_servername(ssl_, TLSEXT_NAMETYPE_host_name)
- : nullptr;
+ return getSSLServerNameFromSSL(ssl_);
#else
throw AsyncSocketException(AsyncSocketException::NOT_SUPPORTED,
- "SNI not supported");
+ "SNI not supported");
#endif
}
const char *AsyncSSLSocket::getSSLServerNameNoThrow() const {
- try {
- return getSSLServerName();
- } catch (AsyncSocketException& ex) {
- return nullptr;
- }
+ return getSSLServerNameFromSSL(ssl_);
}
int AsyncSSLSocket::getSSLVersion() const {
void resetClientHelloParsing(SSL *ssl);
static void clientHelloParsingCallback(int write_p, int version,
int content_type, const void *buf, size_t len, SSL *ssl, void *arg);
+ static const char* getSSLServerNameFromSSL(SSL* ssl);
// http://www.iana.org/assignments/tls-extensiontype-values/tls-extensiontype-values.xhtml
enum class TLSExtension: uint16_t {