Commit ec1f812
committed
Fix OpenSSL::PKey.read that cannot parse PKey in the FIPS mode.
This commit is a workaround to fix this issue below.
The `OpenSSL::PKey.read` fails with the OpenSSL 3.0 FIPS mode enabled.
```
$ openssl genrsa -out key.pem 4096
$ ruby -e "require 'openssl'; OpenSSL::PKey.read(File.read('key.pem'))"
-e:1:in `read': Could not parse PKey (OpenSSL::PKey::PKeyError)
from -e:1:in `<main>'
```
The root cause is that the `OSSL_DECODER_CTX_set_selection` doesn't set the
selection value in the life time of the `OSSL_DECODER_CTX` variable in the
OpenSSL FIPS mode case.
The workaround is to create `OSSL_DECODER_CTX` variable each time, when using
the `OSSL_DECODER_CTX_set_selection` to set a different selection value.1 parent 01361c7 commit ec1f812
1 file changed
+21
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | 104 | | |
| 105 | + | |
| 106 | + | |
108 | 107 | | |
109 | 108 | | |
110 | 109 | | |
| |||
124 | 123 | | |
125 | 124 | | |
126 | 125 | | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
127 | 130 | | |
128 | | - | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
129 | 139 | | |
130 | 140 | | |
131 | 141 | | |
| |||
139 | 149 | | |
140 | 150 | | |
141 | 151 | | |
142 | | - | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
143 | 159 | | |
144 | 160 | | |
145 | 161 | | |
| |||
0 commit comments