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.

132 lines
5.1 KiB

  1. --- a/evhtp.c
  2. +++ b/evhtp.c
  3. @@ -1817,16 +1817,15 @@ _evhtp_ssl_thread_lock(int mode, int typ
  4. #endif
  5. static void
  6. _evhtp_ssl_delete_scache_ent(evhtp_ssl_ctx_t * ctx, evhtp_ssl_sess_t * sess) {
  7. - evhtp_t * htp;
  8. - evhtp_ssl_cfg_t * cfg;
  9. - unsigned char * sid;
  10. - unsigned int slen;
  11. + evhtp_t * htp;
  12. + evhtp_ssl_cfg_t * cfg;
  13. + evhtp_ssl_data_t * sid;
  14. + unsigned int slen;
  15. htp = (evhtp_t *)SSL_CTX_get_app_data(ctx);
  16. cfg = htp->ssl_cfg;
  17. - sid = sess->session_id;
  18. - slen = sess->session_id_length;
  19. + sid = (evhtp_ssl_data_t *)SSL_SESSION_get_id(sess, &slen);
  20. if (cfg->scache_del) {
  21. (cfg->scache_del)(htp, sid, slen);
  22. @@ -1837,14 +1836,17 @@ static int
  23. _evhtp_ssl_add_scache_ent(evhtp_ssl_t * ssl, evhtp_ssl_sess_t * sess) {
  24. evhtp_connection_t * connection;
  25. evhtp_ssl_cfg_t * cfg;
  26. - unsigned char * sid;
  27. + evhtp_ssl_data_t * sid;
  28. int slen;
  29. connection = (evhtp_connection_t *)SSL_get_app_data(ssl);
  30. - cfg = connection->htp->ssl_cfg;
  31. + if (connection->htp == NULL)
  32. + {
  33. + return 0; /* We cannot get the ssl_cfg */
  34. + }
  35. - sid = sess->session_id;
  36. - slen = sess->session_id_length;
  37. + cfg = connection->htp->ssl_cfg;
  38. + sid = (evhtp_ssl_data_t *)SSL_SESSION_get_id(sess, &slen);
  39. SSL_set_timeout(sess, cfg->scache_timeout);
  40. @@ -1856,7 +1858,7 @@ _evhtp_ssl_add_scache_ent(evhtp_ssl_t *
  41. }
  42. static evhtp_ssl_sess_t *
  43. -_evhtp_ssl_get_scache_ent(evhtp_ssl_t * ssl, unsigned char * sid, int sid_len, int * copy) {
  44. +_evhtp_ssl_get_scache_ent(evhtp_ssl_t * ssl, evhtp_ssl_data_t * sid, int sid_len, int * copy) {
  45. evhtp_connection_t * connection;
  46. evhtp_ssl_cfg_t * cfg;
  47. evhtp_ssl_sess_t * sess;
  48. @@ -1898,12 +1900,12 @@ _evhtp_ssl_servername(evhtp_ssl_t * ssl,
  49. connection->vhost_via_sni = 1;
  50. SSL_set_SSL_CTX(ssl, evhtp_vhost->ssl_ctx);
  51. - SSL_set_options(ssl, SSL_CTX_get_options(ssl->ctx));
  52. + SSL_set_options(ssl, SSL_CTX_get_options(SSL_get_SSL_CTX(ssl)));
  53. if ((SSL_get_verify_mode(ssl) == SSL_VERIFY_NONE) ||
  54. (SSL_num_renegotiations(ssl) == 0)) {
  55. - SSL_set_verify(ssl, SSL_CTX_get_verify_mode(ssl->ctx),
  56. - SSL_CTX_get_verify_callback(ssl->ctx));
  57. + SSL_set_verify(ssl, SSL_CTX_get_verify_mode(SSL_get_SSL_CTX(ssl)),
  58. + SSL_CTX_get_verify_callback(SSL_get_SSL_CTX(ssl)));
  59. }
  60. return SSL_TLSEXT_ERR_OK;
  61. @@ -3197,15 +3199,21 @@ evhtp_ssl_init(evhtp_t * htp, evhtp_ssl_
  62. return -1;
  63. }
  64. +#if OPENSSL_VERSION_NUMBER < 0x10100000L
  65. SSL_library_init();
  66. SSL_load_error_strings();
  67. +#endif
  68. RAND_poll();
  69. STACK_OF(SSL_COMP) * comp_methods = SSL_COMP_get_compression_methods();
  70. sk_SSL_COMP_zero(comp_methods);
  71. htp->ssl_cfg = cfg;
  72. +#if OPENSSL_VERSION_NUMBER < 0x10100000L
  73. htp->ssl_ctx = SSL_CTX_new(SSLv23_server_method());
  74. +#else
  75. + htp->ssl_ctx = SSL_CTX_new(TLS_server_method());
  76. +#endif
  77. #if OPENSSL_VERSION_NUMBER >= 0x10000000L
  78. SSL_CTX_set_options(htp->ssl_ctx, SSL_MODE_RELEASE_BUFFERS);
  79. @@ -3242,7 +3250,11 @@ evhtp_ssl_init(evhtp_t * htp, evhtp_ssl_
  80. SSL_CTX_set_verify(htp->ssl_ctx, cfg->verify_peer, cfg->x509_verify_cb);
  81. if (cfg->x509_chk_issued_cb != NULL) {
  82. +#if OPENSSL_VERSION_NUMBER < 0x10100000L
  83. htp->ssl_ctx->cert_store->check_issued = cfg->x509_chk_issued_cb;
  84. +#else
  85. + X509_STORE_set_check_issued(SSL_CTX_get_cert_store(htp->ssl_ctx), cfg->x509_chk_issued_cb);
  86. +#endif
  87. }
  88. if (cfg->verify_depth) {
  89. --- a/evhtp.h
  90. +++ b/evhtp.h
  91. @@ -34,6 +34,11 @@ typedef SSL evhtp_
  92. typedef SSL_CTX evhtp_ssl_ctx_t;
  93. typedef X509 evhtp_x509_t;
  94. typedef X509_STORE_CTX evhtp_x509_store_ctx_t;
  95. +#if OPENSSL_VERSION_NUMBER < 0x10100000L
  96. +typedef unsigned char evhtp_ssl_data_t;
  97. +#else
  98. +typedef const unsigned char evhtp_ssl_data_t;
  99. +#endif
  100. #else
  101. typedef void evhtp_ssl_sess_t;
  102. typedef void evhtp_ssl_t;
  103. @@ -157,9 +162,9 @@ typedef int (*evhtp_headers_iterator)(ev
  104. typedef int (*evhtp_ssl_verify_cb)(int pre_verify, evhtp_x509_store_ctx_t * ctx);
  105. typedef int (*evhtp_ssl_chk_issued_cb)(evhtp_x509_store_ctx_t * ctx, evhtp_x509_t * x, evhtp_x509_t * issuer);
  106. -typedef int (*evhtp_ssl_scache_add)(evhtp_connection_t * connection, unsigned char * sid, int sid_len, evhtp_ssl_sess_t * sess);
  107. -typedef void (*evhtp_ssl_scache_del)(evhtp_t * htp, unsigned char * sid, int sid_len);
  108. -typedef evhtp_ssl_sess_t * (*evhtp_ssl_scache_get)(evhtp_connection_t * connection, unsigned char * sid, int sid_len);
  109. +typedef int (*evhtp_ssl_scache_add)(evhtp_connection_t * connection, evhtp_ssl_data_t * sid, int sid_len, evhtp_ssl_sess_t * sess);
  110. +typedef void (*evhtp_ssl_scache_del)(evhtp_t * htp, evhtp_ssl_data_t * sid, int sid_len);
  111. +typedef evhtp_ssl_sess_t * (*evhtp_ssl_scache_get)(evhtp_connection_t * connection, evhtp_ssl_data_t * sid, int sid_len);
  112. typedef void * (*evhtp_ssl_scache_init)(evhtp_t *);
  113. #define EVHTP_VERSION "1.2.0"