mirror of
https://github.com/allankoechke/jwt-cpp.git
synced 2026-11-30 10:18:40 +00:00
Fix tests for OpenSSL 3.0.0 (#153)
* update signatures of PEM_write_bio_PUBKEY and PEM_write_bio_X509 * run tests with openssl * Update .github/workflows/openssl.yml * fetch openssl from github Co-authored-by: Chris Mc <prince.chrismc@gmail.com>
This commit is contained in:
19
.github/actions/install/openssl/action.yml
vendored
Normal file
19
.github/actions/install/openssl/action.yml
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
name: Install OpenSSL
|
||||
description: Install and setup OpenSSL for linking and building test application
|
||||
inputs:
|
||||
version:
|
||||
description: The desired OpenSSL version to install
|
||||
required: false
|
||||
default: "openssl-3.0.0-beta2"
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- run: |
|
||||
cd /tmp
|
||||
wget https://github.com/openssl/openssl/archive/refs/tags/${{ inputs.version }}.tar.gz
|
||||
tar -zxf /tmp/${{ inputs.version }}.tar.gz
|
||||
cd openssl-${{ inputs.version }}
|
||||
./config --prefix=/tmp --libdir=lib
|
||||
make -j $(nproc)
|
||||
sudo make -j $(nproc) install_sw
|
||||
shell: bash
|
||||
36
.github/workflows/openssl.yml
vendored
Normal file
36
.github/workflows/openssl.yml
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
name: OpenSSL CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [master]
|
||||
pull_request:
|
||||
branches: [master]
|
||||
paths:
|
||||
- "CMakeLists.txt"
|
||||
- "include/jwt-cpp/**"
|
||||
- "tests/cmake/**"
|
||||
- ".github/actions/**"
|
||||
- ".github/workflows/openssl.yml"
|
||||
|
||||
jobs:
|
||||
with-openssl:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
openssl: ["openssl-3.0.0-beta2", "OpenSSL_1_1_1k"]
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: lukka/get-cmake@latest
|
||||
- uses: ./.github/actions/install/gtest
|
||||
- uses: ./.github/actions/install/openssl
|
||||
with:
|
||||
version: ${{ matrix.openssl }}
|
||||
|
||||
- name: configure
|
||||
run: |
|
||||
cmake . -DJWT_BUILD_TESTS=ON -DOPENSSL_ROOT_DIR=/tmp
|
||||
|
||||
- run: make
|
||||
|
||||
- name: test
|
||||
run: ./tests/jwt-cpp-test
|
||||
@@ -40,6 +40,10 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
|
||||
#define OPENSSL3
|
||||
#endif
|
||||
|
||||
// If openssl version less than 1.1
|
||||
#if OPENSSL_VERSION_NUMBER < 0x10100000L
|
||||
#define OPENSSL10
|
||||
|
||||
@@ -73,8 +73,14 @@ EVP_PKEY* X509_get_pubkey(X509* x) {
|
||||
return origMethod(x);
|
||||
}
|
||||
|
||||
int PEM_write_bio_PUBKEY(BIO* bp, EVP_PKEY* x) {
|
||||
static int (*origMethod)(BIO * bp, EVP_PKEY * x) = nullptr;
|
||||
#ifdef OPENSSL3
|
||||
#define OPENSSL_CONST const
|
||||
#else
|
||||
#define OPENSSL_CONST
|
||||
#endif
|
||||
|
||||
int PEM_write_bio_PUBKEY(BIO* bp, OPENSSL_CONST EVP_PKEY* x) {
|
||||
static int (*origMethod)(BIO * bp, OPENSSL_CONST EVP_PKEY * x) = nullptr;
|
||||
if (origMethod == nullptr) origMethod = (decltype(origMethod))dlsym(RTLD_NEXT, "PEM_write_bio_PUBKEY");
|
||||
bool fail = fail_PEM_write_bio_PUBKEY & 1;
|
||||
fail_PEM_write_bio_PUBKEY = fail_PEM_write_bio_PUBKEY >> 1;
|
||||
@@ -84,8 +90,8 @@ int PEM_write_bio_PUBKEY(BIO* bp, EVP_PKEY* x) {
|
||||
return origMethod(bp, x);
|
||||
}
|
||||
|
||||
int PEM_write_bio_X509(BIO* bp, X509* x) {
|
||||
static int (*origMethod)(BIO * bp, X509 * x) = nullptr;
|
||||
int PEM_write_bio_X509(BIO* bp, OPENSSL_CONST X509* x) {
|
||||
static int (*origMethod)(BIO * bp, OPENSSL_CONST X509 * x) = nullptr;
|
||||
if (origMethod == nullptr) origMethod = (decltype(origMethod))dlsym(RTLD_NEXT, "PEM_write_bio_X509");
|
||||
bool fail = fail_PEM_write_bio_cert & 1;
|
||||
fail_PEM_write_bio_cert = fail_PEM_write_bio_cert >> 1;
|
||||
|
||||
Reference in New Issue
Block a user