logo

overlay

My own overlay for experimentations, use with caution, no support is provided git clone https://anongit.hacktivis.me/git/overlay.git/

gzsig-20060130-x509.c-Update-for-OpenSSL-3.x.patch (1865B)


  1. From 7ac9a2f8c3b275919ab2df012a5b223880e13f39 Mon Sep 17 00:00:00 2001
  2. From: "Haelwenn (lanodan) Monnier" <contact@hacktivis.me>
  3. Date: Sat, 13 Sep 2025 07:29:36 +0200
  4. Subject: [PATCH 3/4] x509.c: Update for OpenSSL 3.x
  5. ---
  6. x509.c | 38 ++++++++++++++++++++++++--------------
  7. 1 file changed, 24 insertions(+), 14 deletions(-)
  8. diff --git a/x509.c b/x509.c
  9. index 99dcc52..53f51fc 100644
  10. --- a/x509.c
  11. +++ b/x509.c
  12. @@ -75,18 +75,24 @@ x509_load_public(struct key *k, struct iovec *iov)
  13. return (-1);
  14. evp = X509_get_pubkey(cert);
  15. -
  16. - if (evp->type == EVP_PKEY_RSA) {
  17. +
  18. + int evp_id = EVP_PKEY_base_id(evp);
  19. + switch(evp_id)
  20. + {
  21. + case EVP_PKEY_RSA:
  22. k->type = KEY_RSA;
  23. - k->data = (void *)RSAPublicKey_dup(evp->pkey.rsa);
  24. - } else if (evp->type == EVP_PKEY_DSA) {
  25. + k->data = EVP_PKEY_get1_RSA(evp);
  26. + break;
  27. + case EVP_PKEY_DSA:
  28. k->type = KEY_DSA;
  29. - k->data = (void *)evp->pkey.dsa;
  30. - evp->pkey.dsa = NULL; /* XXX */
  31. - } else {
  32. + k->data = EVP_PKEY_get1_DSA(evp);
  33. + break;
  34. + default:
  35. + fprintf(stderr, "gzsig: error: Unknown key type %d\n", evp_id);
  36. X509_free(cert);
  37. return (-1);
  38. }
  39. +
  40. X509_free(cert);
  41. return (0);
  42. @@ -119,15 +125,19 @@ x509_load_private(struct key *k, struct iovec *iov)
  43. if (evp == NULL)
  44. return (-1);
  45. - if (evp->type == EVP_PKEY_RSA) {
  46. + int evp_id = EVP_PKEY_base_id(evp);
  47. + switch(evp_id)
  48. + {
  49. + case EVP_PKEY_RSA:
  50. k->type = KEY_RSA;
  51. - k->data = (void *)evp->pkey.rsa;
  52. - evp->pkey.rsa = NULL; /* XXX */
  53. - } else if (evp->type == EVP_PKEY_DSA) {
  54. + k->data = EVP_PKEY_get1_RSA(evp);
  55. + break;
  56. + case EVP_PKEY_DSA:
  57. k->type = KEY_DSA;
  58. - k->data = (void *)evp->pkey.dsa;
  59. - evp->pkey.dsa = NULL; /* XXX */
  60. - } else {
  61. + k->data = EVP_PKEY_get1_DSA(evp);
  62. + break;
  63. + default:
  64. + fprintf(stderr, "gzsig: error: Unknown key type %d\n", evp_id);
  65. EVP_PKEY_free(evp);
  66. return (-1);
  67. }
  68. --
  69. 2.49.1