You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

169 lines
6.0 KiB

  1. --- a/ext/ftp/php_ftp.c
  2. +++ b/ext/ftp/php_ftp.c
  3. @@ -320,12 +320,14 @@ static void ftp_destructor_ftpbuf(zend_resource *rsrc)
  4. PHP_MINIT_FUNCTION(ftp)
  5. {
  6. #ifdef HAVE_FTP_SSL
  7. +#if OPENSSL_VERSION_NUMBER < 0x10100000L
  8. SSL_library_init();
  9. OpenSSL_add_all_ciphers();
  10. OpenSSL_add_all_digests();
  11. OpenSSL_add_all_algorithms();
  12. SSL_load_error_strings();
  13. +#endif
  14. #endif
  15. le_ftpbuf = zend_register_list_destructors_ex(ftp_destructor_ftpbuf, NULL, le_ftpbuf_name, module_number);
  16. --- a/ext/openssl/openssl.c
  17. +++ b/ext/openssl/openssl.c
  18. @@ -683,6 +683,12 @@ static const unsigned char *ASN1_STRING_get0_data(const ASN1_STRING *asn1)
  19. return M_ASN1_STRING_data(asn1);
  20. }
  21. +#define OpenSSL_version OpenSSL_version
  22. +#define OPENSSL_VERSION OPENSSL_VERSION
  23. +#define X509_getm_notBefore X509_get_notBefore
  24. +#define X509_getm_notAfter X509_get_notAfter
  25. +#define EVP_CIPHER_CTX_reset EVP_CIPHER_CTX_cleanup
  26. +
  27. #if PHP_OPENSSL_API_VERSION < 0x10002
  28. static int X509_get_signature_nid(const X509 *x)
  29. @@ -1587,7 +1593,7 @@ PHP_MINFO_FUNCTION(openssl)
  30. {
  31. php_info_print_table_start();
  32. php_info_print_table_row(2, "OpenSSL support", "enabled");
  33. - php_info_print_table_row(2, "OpenSSL Library Version", SSLeay_version(SSLEAY_VERSION));
  34. + php_info_print_table_row(2, "OpenSSL Library Version", OpenSSL_version(OPENSSL_VERSION));
  35. php_info_print_table_row(2, "OpenSSL Header Version", OPENSSL_VERSION_TEXT);
  36. php_info_print_table_row(2, "Openssl default config", default_ssl_conf_filename);
  37. php_info_print_table_end();
  38. @@ -2361,11 +2367,11 @@ PHP_FUNCTION(openssl_x509_parse)
  39. add_assoc_string(return_value, "serialNumberHex", hex_serial);
  40. OPENSSL_free(hex_serial);
  41. - php_openssl_add_assoc_asn1_string(return_value, "validFrom", X509_get_notBefore(cert));
  42. - php_openssl_add_assoc_asn1_string(return_value, "validTo", X509_get_notAfter(cert));
  43. + php_openssl_add_assoc_asn1_string(return_value, "validFrom", X509_getm_notBefore(cert));
  44. + php_openssl_add_assoc_asn1_string(return_value, "validTo", X509_getm_notAfter(cert));
  45. - add_assoc_long(return_value, "validFrom_time_t", php_openssl_asn1_time_to_time_t(X509_get_notBefore(cert)));
  46. - add_assoc_long(return_value, "validTo_time_t", php_openssl_asn1_time_to_time_t(X509_get_notAfter(cert)));
  47. + add_assoc_long(return_value, "validFrom_time_t", php_openssl_asn1_time_to_time_t(X509_getm_notBefore(cert)));
  48. + add_assoc_long(return_value, "validTo_time_t", php_openssl_asn1_time_to_time_t(X509_getm_notAfter(cert)));
  49. tmpstr = (char *)X509_alias_get0(cert, NULL);
  50. if (tmpstr) {
  51. @@ -3455,8 +3461,8 @@ PHP_FUNCTION(openssl_csr_sign)
  52. php_openssl_store_errors();
  53. goto cleanup;
  54. }
  55. - X509_gmtime_adj(X509_get_notBefore(new_cert), 0);
  56. - X509_gmtime_adj(X509_get_notAfter(new_cert), 60*60*24*(long)num_days);
  57. + X509_gmtime_adj(X509_getm_notBefore(new_cert), 0);
  58. + X509_gmtime_adj(X509_getm_notAfter(new_cert), 60*60*24*(long)num_days);
  59. i = X509_set_pubkey(new_cert, key);
  60. if (!i) {
  61. php_openssl_store_errors();
  62. @@ -6072,7 +6078,7 @@ PHP_FUNCTION(openssl_seal)
  63. /* allocate one byte extra to make room for \0 */
  64. buf = emalloc(data_len + EVP_CIPHER_CTX_block_size(ctx));
  65. - EVP_CIPHER_CTX_cleanup(ctx);
  66. + EVP_CIPHER_CTX_reset(ctx);
  67. if (EVP_SealInit(ctx, cipher, eks, eksl, &iv_buf[0], pkeys, nkeys) <= 0 ||
  68. !EVP_SealUpdate(ctx, buf, &len1, (unsigned char *)data, (int)data_len) ||
  69. @@ -6622,7 +6628,7 @@ PHP_FUNCTION(openssl_encrypt)
  70. if (free_iv) {
  71. efree(iv);
  72. }
  73. - EVP_CIPHER_CTX_cleanup(cipher_ctx);
  74. + EVP_CIPHER_CTX_reset(cipher_ctx);
  75. EVP_CIPHER_CTX_free(cipher_ctx);
  76. }
  77. /* }}} */
  78. @@ -6709,7 +6715,7 @@ PHP_FUNCTION(openssl_decrypt)
  79. if (base64_str) {
  80. zend_string_release(base64_str);
  81. }
  82. - EVP_CIPHER_CTX_cleanup(cipher_ctx);
  83. + EVP_CIPHER_CTX_reset(cipher_ctx);
  84. EVP_CIPHER_CTX_free(cipher_ctx);
  85. }
  86. /* }}} */
  87. --- a/ext/openssl/xp_ssl.c
  88. +++ b/ext/openssl/xp_ssl.c
  89. @@ -56,8 +56,21 @@
  90. #define HAVE_SSL3 1
  91. #endif
  92. +#if PHP_OPENSSL_API_VERSION >= 0x10100
  93. +#define HAVE_TLS 1
  94. +#endif
  95. +
  96. +#ifndef OPENSSL_NO_TLS1_METHOD
  97. +#define HAVE_TLS1 1
  98. +#endif
  99. +
  100. +#ifndef OPENSSL_NO_TLS1_1_METHOD
  101. #define HAVE_TLS11 1
  102. +#endif
  103. +
  104. +#ifndef OPENSSL_NO_TLS1_2_METHOD
  105. #define HAVE_TLS12 1
  106. +#endif
  107. #ifndef OPENSSL_NO_ECDH
  108. #define HAVE_ECDH 1
  109. @@ -78,9 +91,10 @@
  110. #define STREAM_CRYPTO_IS_CLIENT (1<<0)
  111. #define STREAM_CRYPTO_METHOD_SSLv2 (1<<1)
  112. #define STREAM_CRYPTO_METHOD_SSLv3 (1<<2)
  113. -#define STREAM_CRYPTO_METHOD_TLSv1_0 (1<<3)
  114. -#define STREAM_CRYPTO_METHOD_TLSv1_1 (1<<4)
  115. -#define STREAM_CRYPTO_METHOD_TLSv1_2 (1<<5)
  116. +#define STREAM_CRYPTO_METHOD_TLS (1<<3)
  117. +#define STREAM_CRYPTO_METHOD_TLSv1_0 (1<<4)
  118. +#define STREAM_CRYPTO_METHOD_TLSv1_1 (1<<5)
  119. +#define STREAM_CRYPTO_METHOD_TLSv1_2 (1<<6)
  120. /* Simplify ssl context option retrieval */
  121. #define GET_VER_OPT(name) \
  122. @@ -960,9 +974,23 @@ static const SSL_METHOD *php_openssl_select_crypto_method(zend_long method_value
  123. php_error_docref(NULL, E_WARNING,
  124. "SSLv3 unavailable in the OpenSSL library against which PHP is linked");
  125. return NULL;
  126. +#endif
  127. + } else if (method_value == STREAM_CRYPTO_METHOD_TLS) {
  128. +#ifdef HAVE_TLS
  129. + return is_client ? TLS_client_method() : TLS_server_method();
  130. +#else
  131. + php_error_docref(NULL, E_WARNING,
  132. + "TLS unavailable in the OpenSSL library against which PHP is linked");
  133. + return NULL;
  134. #endif
  135. } else if (method_value == STREAM_CRYPTO_METHOD_TLSv1_0) {
  136. +#ifdef HAVE_TLS1
  137. return is_client ? TLSv1_client_method() : TLSv1_server_method();
  138. +#else
  139. + php_error_docref(NULL, E_WARNING,
  140. + "TLSv1 unavailable in the OpenSSL library against which PHP is linked");
  141. + return NULL;
  142. +#endif
  143. } else if (method_value == STREAM_CRYPTO_METHOD_TLSv1_1) {
  144. #ifdef HAVE_TLS11
  145. return is_client ? TLSv1_1_client_method() : TLSv1_1_server_method();
  146. @@ -1014,9 +1042,11 @@ static int php_openssl_get_crypto_method_ctx_flags(int method_flags) /* {{{ */
  147. ssl_ctx_options |= SSL_OP_NO_SSLv3;
  148. }
  149. #endif
  150. +#ifdef HAVE_TLS1
  151. if (!(method_flags & STREAM_CRYPTO_METHOD_TLSv1_0)) {
  152. ssl_ctx_options |= SSL_OP_NO_TLSv1;
  153. }
  154. +#endif
  155. #ifdef HAVE_TLS11
  156. if (!(method_flags & STREAM_CRYPTO_METHOD_TLSv1_1)) {
  157. ssl_ctx_options |= SSL_OP_NO_TLSv1_1;