+#if PHP_HTTP_CURL_VERSION(7,34,0)
+ {
+ zval ti_array, subarray;
+ struct curl_tlssessioninfo *ti;
+
+ if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_TLS_SESSION, &ti)) {
+ char *backend;
+
+ ZVAL_NULL(&subarray);
+ array_init(&ti_array);
+
+ switch (ti->backend) {
+ case CURLSSLBACKEND_NONE:
+ backend = "none";
+ break;
+ case CURLSSLBACKEND_OPENSSL:
+ backend = "openssl";
+#ifdef PHP_HTTP_HAVE_OPENSSL
+ {
+ SSL_CTX *ctx = ti->internals;
+
+ array_init(&subarray);
+ add_assoc_long_ex(&subarray, ZEND_STRL("number"), SSL_CTX_sess_number(ctx));
+ add_assoc_long_ex(&subarray, ZEND_STRL("connect"), SSL_CTX_sess_connect(ctx));
+ add_assoc_long_ex(&subarray, ZEND_STRL("connect_good"), SSL_CTX_sess_connect_good(ctx));
+ add_assoc_long_ex(&subarray, ZEND_STRL("connect_renegotiate"), SSL_CTX_sess_connect_renegotiate(ctx));
+ add_assoc_long_ex(&subarray, ZEND_STRL("hits"), SSL_CTX_sess_hits(ctx));
+ add_assoc_long_ex(&subarray, ZEND_STRL("cache_full"), SSL_CTX_sess_cache_full(ctx));
+ }
+#endif
+ break;
+ case CURLSSLBACKEND_GNUTLS:
+ backend = "gnutls";
+#ifdef PHP_HTTP_HAVE_GNUTLS
+ {
+ gnutls_session_t sess = ti->internals;
+ char *desc;
+
+ array_init(&subarray);
+ if ((desc = gnutls_session_get_desc(sess))) {
+ add_assoc_string_ex(&subarray, ZEND_STRL("desc"), desc);
+ gnutls_free(desc);
+ }
+ add_assoc_bool_ex(&subarray, ZEND_STRL("resumed"), gnutls_session_is_resumed(sess));
+ }
+#endif
+ break;
+ case CURLSSLBACKEND_NSS:
+ backend = "nss";
+ break;
+#if !PHP_HTTP_CURL_VERSION(7,39,0)
+ case CURLSSLBACKEND_QSOSSL:
+ backend = "qsossl";
+ break;
+#endif
+ case CURLSSLBACKEND_GSKIT:
+ backend = "gskit";
+ break;
+ case CURLSSLBACKEND_POLARSSL:
+ backend = "polarssl";
+ break;
+ case CURLSSLBACKEND_CYASSL:
+ backend = "cyassl";
+ break;
+ case CURLSSLBACKEND_SCHANNEL:
+ backend = "schannel";
+ break;
+ case CURLSSLBACKEND_DARWINSSL:
+ backend = "darwinssl";
+ break;
+ default:
+ backend = "unknown";
+ }
+ add_assoc_string_ex(&ti_array, ZEND_STRL("backend"), backend);
+ add_assoc_zval_ex(&ti_array, ZEND_STRL("internals"), &subarray);
+ zend_hash_str_update(info, "tls_session", lenof("tls_session"), &ti_array);
+ }
+ }
+#endif
+