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.

89 lines
2.5 KiB

  1. --- a/src/context.c
  2. +++ b/src/context.c
  3. @@ -17,6 +17,7 @@
  4. #include <openssl/err.h>
  5. #include <openssl/x509.h>
  6. #include <openssl/x509v3.h>
  7. +#include <openssl/dh.h>
  8. #include <lua.h>
  9. #include <lauxlib.h>
  10. @@ -819,7 +820,9 @@ LSEC_API int luaopen_ssl_context(lua_State *L)
  11. luaL_newlib(L, meta_index);
  12. lua_setfield(L, -2, "__index");
  13. +#ifndef OPENSSL_NO_EC
  14. lsec_load_curves(L);
  15. +#endif
  16. /* Return the module */
  17. luaL_newlib(L, funcs);
  18. --- a/src/ssl.c
  19. +++ b/src/ssl.c
  20. @@ -857,6 +857,7 @@ static luaL_Reg funcs[] = {
  21. */
  22. LSEC_API int luaopen_ssl_core(lua_State *L)
  23. {
  24. +#if OPENSSL_VERSION_NUMBER<0x10100000L
  25. /* Initialize SSL */
  26. if (!SSL_library_init()) {
  27. lua_pushstring(L, "unable to initialize SSL library");
  28. @@ -864,6 +865,7 @@ LSEC_API int luaopen_ssl_core(lua_State *L)
  29. }
  30. OpenSSL_add_all_algorithms();
  31. SSL_load_error_strings();
  32. +#endif
  33. #if defined(WITH_LUASOCKET)
  34. /* Initialize internal library */
  35. --- a/src/x509.c
  36. +++ b/src/x509.c
  37. @@ -42,6 +42,10 @@
  38. #define LSEC_ASN1_STRING_data(x) ASN1_STRING_data(x)
  39. #endif
  40. +#if OPENSSL_VERSION_NUMBER < 0x10100000L
  41. +#define X509_get0_notBefore X509_get_notBefore
  42. +#define X509_get0_notAfter X509_get_notAfter
  43. +#endif
  44. static const char* hex_tab = "0123456789abcdef";
  45. @@ -174,7 +178,7 @@ static void push_asn1_string(lua_State* L, ASN1_STRING *string, int encode)
  46. /**
  47. * Return a human readable time.
  48. */
  49. -static int push_asn1_time(lua_State *L, ASN1_UTCTIME *tm)
  50. +static int push_asn1_time(lua_State *L, const ASN1_UTCTIME *tm)
  51. {
  52. char *tmp;
  53. long size;
  54. @@ -490,8 +494,8 @@ static int meth_valid_at(lua_State* L)
  55. {
  56. X509* cert = lsec_checkx509(L, 1);
  57. time_t time = luaL_checkinteger(L, 2);
  58. - lua_pushboolean(L, (X509_cmp_time(X509_get_notAfter(cert), &time) >= 0
  59. - && X509_cmp_time(X509_get_notBefore(cert), &time) <= 0));
  60. + lua_pushboolean(L, (X509_cmp_time(X509_get0_notAfter(cert), &time) >= 0
  61. + && X509_cmp_time(X509_get0_notBefore(cert), &time) <= 0));
  62. return 1;
  63. }
  64. @@ -519,7 +523,7 @@ static int meth_serial(lua_State *L)
  65. static int meth_notbefore(lua_State *L)
  66. {
  67. X509* cert = lsec_checkx509(L, 1);
  68. - return push_asn1_time(L, X509_get_notBefore(cert));
  69. + return push_asn1_time(L, X509_get0_notBefore(cert));
  70. }
  71. /**
  72. @@ -528,7 +532,7 @@ static int meth_notbefore(lua_State *L)
  73. static int meth_notafter(lua_State *L)
  74. {
  75. X509* cert = lsec_checkx509(L, 1);
  76. - return push_asn1_time(L, X509_get_notAfter(cert));
  77. + return push_asn1_time(L, X509_get0_notAfter(cert));
  78. }
  79. /**