@@ -54,27 +54,179 @@ $ bundle exec rake test
54
54
55
55
### With different versions of OpenSSL
56
56
57
- Ruby OpenSSL supports various versions of OpenSSL library. The test suite needs
58
- to pass on all supported combinations.
57
+ Ruby OpenSSL supports various versions of the OpenSSL library. The test suite
58
+ needs to pass on all supported combinations.
59
59
60
- Similarly to when installing ` openssl ` gem via the ` gem ` command,
61
- you can pass a ` --with-openssl-dir ` argument to ` rake compile `
62
- to specify the OpenSSL library to build against.
60
+ If you want to test, debug, report an issue, or contribute to the Ruby OpenSSL
61
+ or [ the OpenSSL project] ( https://www.openssl.org/ ) in the non-FIPS or
62
+ the [ FIPS] ( https://github.com/openssl/openssl/blob/master/README-FIPS.md ) case,
63
+ compiling OpenSSL from the source by yourself is a good practice.
63
64
65
+ The following steps are tested in Linux and GCC environment. You can adjust the
66
+ commands in the steps for a different environment.
67
+
68
+ To download the OpenSSL source from the Git repository, you can run the following
69
+ commands:
70
+
71
+ ```
72
+ $ git clone https://github.com/openssl/openssl.git
73
+ $ cd openssl
74
+ ```
75
+
76
+ You see the ` master ` branch used as a development branch. Testing against the
77
+ latest OpenSSL master branch is a good practice to report an issue to the
78
+ OpenSSL project.
79
+
80
+ ```
81
+ $ git branch | grep '^*'
82
+ * master
83
+ ```
84
+
85
+ If you test against the latest stable branch, you can run the following command.
86
+ In this example, the ` openssl-3.1 ` branch is the stable branch of OpenSSL 3.1
87
+ series.
88
+
89
+ ```
90
+ $ git checkout openssl-3.1
91
+ ```
92
+
93
+ To configure OpenSSL, you can run the following commands.
94
+
95
+ In this example, we use the ` OPENSSL_DIR ` environment variable to specify the
96
+ OpenSSL installed directory for convenience. Including the commit hash in the
97
+ directory name is a good practice.
98
+
99
+ ```
100
+ $ git rev-parse --short HEAD
101
+ 0bf18140f4
102
+
103
+ $ OPENSSL_DIR=$HOME/.openssl/openssl-fips-debug-0bf18140f4
104
+ ```
105
+
106
+ The following configuration options are useful in this case.
107
+ You can check
108
+ [ OpenSSL installation document] ( https://github.com/openssl/openssl/blob/master/INSTALL.md )
109
+ for details.
110
+
111
+ * ` enable-fips ` : Add an option to run with the OpenSSL FIPS module.
112
+ * ` enable-trace ` : Add an option to enabling tracing log. You can trace logs by
113
+ implementing a code. See the man page
114
+ [ OSSL_TRACE(3)] ( https://www.openssl.org/docs/man3.0/man3/OSSL_TRACE.html ) for
115
+ details.
116
+ * compiler flags
117
+ * ` -Wl,-rpath,$(LIBRPATH) ` : Set the runtime shared library path to run the
118
+ ` openssl ` command without the ` LD_LIBRARY_PATH ` . You can check
119
+ [ this document] ( https://github.com/openssl/openssl/blob/master/NOTES-UNIX.md )
120
+ for details.
121
+ * ` -O0 -g3 -ggdb3 -gdwarf-5 ` : You can set debugging compiler flags.
122
+
123
+ ```
124
+ $ ./Configure \
125
+ --prefix=$OPENSSL_DIR \
126
+ --libdir=lib \
127
+ enable-fips \
128
+ enable-trace \
129
+ '-Wl,-rpath,$(LIBRPATH)' \
130
+ -O0 -g3 -ggdb3 -gdwarf-5
131
+ $ make -j4
132
+ $ make install
64
133
```
65
- $ ( curl -OL https://ftp.openssl.org/source/openssl-3.0.1.tar.gz &&
66
- tar xf openssl-3.0.1.tar.gz &&
67
- cd openssl-3.0.1 &&
68
- ./config --prefix=$HOME/.openssl/openssl-3.0.1 --libdir=lib &&
69
- make -j4 &&
70
- make install )
71
134
72
- $ # in Ruby/OpenSSL's source directory
135
+ To print installed OpenSSL version, you can run the following command:
136
+
137
+ ```
138
+ $ $OPENSSL_DIR/bin/openssl version
139
+ OpenSSL 3.2.0-alpha3-dev (Library: OpenSSL 3.2.0-alpha3-dev )
140
+ ```
141
+
142
+ Change the current working directory into Ruby OpenSSL's source directory.
143
+
144
+ To compile Ruby OpenSSL, you can run the following commands:
145
+
146
+ Similarly to when installing ` openssl ` gem via the ` gem ` command, you can pass a
147
+ ` --with-openssl-dir ` argument to ` rake compile ` to specify the OpenSSL library
148
+ to build against.
149
+
150
+ * ` MAKEFLAGS="V=1" ` : Enable the compiler command lines to print in
151
+ the log.
152
+ * ` RUBY_OPENSSL_EXTCFLAGS ` : Set extra compiler flags to compile Ruby OpenSSL.
153
+
154
+ ```
73
155
$ bundle exec rake clean
74
- $ bundle exec rake compile -- --with-openssl-dir=$HOME/.openssl/openssl-3.0.1
156
+ $ MAKEFLAGS="V=1" \
157
+ RUBY_OPENSSL_EXTCFLAGS="-O0 -g3 -ggdb3 -gdwarf-5" \
158
+ bundle exec rake compile -- --with-openssl-dir=$OPENSSL_DIR
159
+ ```
160
+
161
+ #### Testing normally in non-FIPS case
162
+
163
+ To test Ruby OpenSSL, you can run the following command:
164
+
165
+ ```
75
166
$ bundle exec rake test
76
167
```
77
168
169
+ #### Testing in FIPS case
170
+
171
+ To use OpenSSL 3.0 or later versions in a FIPS-approved manner, you must load the
172
+ ` fips ` and ` base ` providers, and also use the property query ` fips=yes ` . The
173
+ property query is used when fetching cryptographic algorithm implementations.
174
+ This must be done at the startup of a process to avoid implicitly loading the
175
+ ` default ` provider which has the non-FIPS cryptographic algorithm
176
+ implementations. See also the man page
177
+ [ fips_module(7)] ( https://www.openssl.org/docs/manmaster/man7/fips_module.html ) .
178
+
179
+ You can set this in your OpenSSL configuration file by either appropriately
180
+ modifying the default OpenSSL configuration file located at
181
+ ` OpenSSL::Config::DEFAULT_CONFIG_FILE ` or temporarily overriding it with the
182
+ ` OPENSSL_CONF ` environment variable.
183
+
184
+ In this example, we explain on the latter way.
185
+
186
+ You can create a OpenSSL FIPS config ` openssl_fips.cnf ` file based on the
187
+ ` openssl_fips.cnf.tmpl ` file in this repository, and replacing the placeholder
188
+ ` OPENSSL_DIR ` with your OpenSSL installed directory.
189
+
190
+ ```
191
+ $ sed -e "s|OPENSSL_DIR|$OPENSSL_DIR|" tool/openssl_fips.cnf.tmpl | \
192
+ tee $OPENSSL_DIR/ssl/openssl_fips.cnf
193
+ ```
194
+
195
+ You can see the base and fips providers by running the following command if you
196
+ setup the OpenSSL FIPS config file properly.
197
+
198
+ ```
199
+ $ OPENSSL_CONF=$OPENSSL_DIR/ssl/openssl_fips.cnf \
200
+ $OPENSSL_DIR/bin/openssl list -providers
201
+ Providers:
202
+ base
203
+ name: OpenSSL Base Provider
204
+ version: 3.2.0
205
+ status: active
206
+ fips
207
+ name: OpenSSL FIPS Provider
208
+ version: 3.2.0
209
+ status: active
210
+ ```
211
+
212
+ You can run the current tests in the FIPS module case used in the GitHub
213
+ Actions file ` test.yml ` explained in a later sentence.
214
+
215
+ ```
216
+ $ OPENSSL_CONF=$OPENSSL_DIR/ssl/openssl_fips.cnf \
217
+ bundle exec rake test_fips
218
+ ```
219
+
220
+ You can also run the all the tests in the FIPS module case. You see many
221
+ failures. We are working in progress to fix the failures. Your contribution is
222
+ welcome.
223
+
224
+ ```
225
+ $ OPENSSL_CONF=$OPENSSL_DIR/ssl/openssl_fips.cnf \
226
+ TEST_RUBY_OPENSSL_FIPS_ENABLED=true \
227
+ bundle exec rake test
228
+ ```
229
+
78
230
The GitHub Actions workflow file
79
231
[ ` test.yml ` ] ( https://github.com/ruby/openssl/tree/master/.github/workflows/test.yml )
80
232
contains useful information for building OpenSSL/LibreSSL and testing against
0 commit comments