Skip to content

Commit 18b0172

Browse files
committed
CI: Add OpenSSL FIPS mode case.
test/openssl/fixtures/ssl/openssl_fips.cnf.tmpl: I referred to the following document for the openssl config file for FIPS mode. <https://www.openssl.org/docs/manmaster/man7/fips_module.html> - Making all applications use the FIPS module by default It seems that the `.include` syntax only requires the absolute path. So, the placeholder OPENSSL_DIR in the template file is replaced with the actual OpenSSL directory. .github/workflows/test.yml: The `TEST_RUBY_OPENSSL_FIPS_ENABLED` environment variable is set in the FIPS mode CI case. It can be used in the unit tests.
1 parent 037c181 commit 18b0172

File tree

2 files changed

+51
-2
lines changed

2 files changed

+51
-2
lines changed

.github/workflows/test.yml

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151

5252
test-openssls:
5353
name: >-
54-
${{ matrix.openssl }}
54+
${{ matrix.openssl }} ${{ matrix.name_extra || '' }}
5555
runs-on: ${{ matrix.os }}
5656
strategy:
5757
fail-fast: false
@@ -70,6 +70,9 @@ jobs:
7070
- libressl-3.5.3
7171
- libressl-3.6.1
7272
- libressl-3.7.0 # Development release
73+
fips_enabled: [ false ]
74+
include:
75+
- { os: ubuntu-latest, ruby: "3.0", openssl: openssl-3.0.8, fips_enabled: true, append_configure: 'enable-fips', name_extra: 'fips' }
7376
steps:
7477
- name: repo checkout
7578
uses: actions/checkout@v3
@@ -83,7 +86,7 @@ jobs:
8386
tar xf ${{ matrix.openssl }}.tar.gz && cd ${{ matrix.openssl }}
8487
# shared is required for 1.0.x.
8588
./Configure --prefix=$HOME/.openssl/${{ matrix.openssl }} --libdir=lib \
86-
shared linux-x86_64
89+
shared linux-x86_64 ${{ matrix.append_configure }}
8790
make depend
8891
;;
8992
libressl-*)
@@ -98,6 +101,26 @@ jobs:
98101
make -j4
99102
make install_sw
100103
104+
- name: prepare openssl fips
105+
run: make install_fips
106+
working-directory: tmp/build-openssl/${{ matrix.openssl }}
107+
if: matrix.fips_enabled
108+
109+
- name: set the open installed directory
110+
run: >
111+
sed -e "s|OPENSSL_DIR|$HOME/.openssl/${{ matrix.openssl }}|"
112+
test/openssl/fixtures/ssl/openssl_fips.cnf.tmpl >
113+
test/openssl/fixtures/ssl/openssl_fips.cnf
114+
if: matrix.fips_enabled
115+
116+
- name: set openssl config file path for fips.
117+
run: echo "OPENSSL_CONF=$(pwd)/test/openssl/fixtures/ssl/openssl_fips.cnf" >> $GITHUB_ENV
118+
if: matrix.fips_enabled
119+
120+
- name: set fips enviornment variable for testing.
121+
run: echo "TEST_RUBY_OPENSSL_FIPS_ENABLED=true" >> $GITHUB_ENV
122+
if: matrix.fips_enabled
123+
101124
- name: load ruby
102125
uses: ruby/setup-ruby@v1
103126
with:
@@ -112,3 +135,10 @@ jobs:
112135
- name: test
113136
run: rake test TESTOPTS="-v --no-show-detail-immediately" OSSL_MDEBUG=1
114137
timeout-minutes: 5
138+
if: ${{ !matrix.fips_enabled }}
139+
140+
# Run only the passing tests on the FIPS mode as a temporary workaround.
141+
# TODO Fix other tests, and run all the tests on FIPS mode.
142+
- name: test on fips mode
143+
run: ruby -Ilib test/openssl/test_fips.rb
144+
if: matrix.fips_enabled
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
config_diagnostics = 1
2+
openssl_conf = openssl_init
3+
4+
# It seems that the .include needs an absolute path.
5+
.include OPENSSL_DIR/ssl/fipsmodule.cnf
6+
7+
[openssl_init]
8+
providers = provider_sect
9+
alg_section = algorithm_sect
10+
11+
[provider_sect]
12+
fips = fips_sect
13+
base = base_sect
14+
15+
[base_sect]
16+
activate = 1
17+
18+
[algorithm_sect]
19+
default_properties = fips=yes

0 commit comments

Comments
 (0)