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.

31 lines
887 B

  1. --- a/src/csr.c
  2. +++ b/src/csr.c
  3. @@ -38,7 +38,7 @@ static LUA_FUNCTION(openssl_csr_read)
  4. return openssl_pushresult(L, 0);
  5. }
  6. -
  7. +#if OPENSSL_VERSION_NUMBER < 0x10100000L
  8. static X509 *X509_REQ_to_X509_ex(X509_REQ *r, int days, EVP_PKEY *pkey, const EVP_MD* md)
  9. {
  10. X509 *ret = NULL;
  11. @@ -91,14 +91,19 @@ static X509 *X509_REQ_to_X509_ex(X509_RE
  12. }
  13. return (ret);
  14. }
  15. +#endif
  16. static LUA_FUNCTION(openssl_csr_to_x509)
  17. {
  18. X509_REQ * csr = CHECK_OBJECT(1, X509_REQ, "openssl.x509_req");
  19. EVP_PKEY * pkey = CHECK_OBJECT(2, EVP_PKEY, "openssl.evp_pkey");
  20. int days = luaL_optint(L, 3, 365);
  21. +#if OPENSSL_VERSION_NUMBER < 0x10100000L
  22. const EVP_MD* md = get_digest(L, 4, "sha256");
  23. X509* cert = X509_REQ_to_X509_ex(csr, days, pkey, md);
  24. +#else
  25. + X509* cert = X509_REQ_to_X509(csr, days, pkey);
  26. +#endif
  27. if (cert)
  28. {
  29. PUSH_OBJECT(cert, "openssl.x509");