|
20 | 20 | license_file "LICENSE" |
21 | 21 | skip_transitive_dependency_licensing true |
22 | 22 |
|
23 | | -dependency "cacerts" |
24 | | -dependency "openssl-fips" if fips_mode? |
| 23 | +# https://github.com/chef/omnibus-software/pull/2032 |
| 24 | +default_version "3.6.0" # # do not remove - Rapid7 custom - do not remove |
25 | 25 |
|
26 | | -default_version "1.1.1t" # # do not remove - Rapid7 custom - do not remove |
| 26 | +dependency "cacerts" |
| 27 | +dependency "openssl-fips" if fips_mode? && !(version.satisfies?(">= 3.0.0")) |
| 28 | +# On 32-bit ARM, GCC emits calls to libatomic for 64-bit atomic operations. |
| 29 | +# 64-bit ARM (aarch64) has native 64-bit atomics and doesn't need this. |
| 30 | +dependency "libatomic" if linux? && RUBY_PLATFORM =~ /armv7l/ |
27 | 31 |
|
28 | 32 | # Openssl builds engines as libraries into a special directory. We need to include |
29 | 33 | # that directory in lib_dirs so omnibus can sign them during macOS deep signing. |
|
47 | 51 | internal_source url: "#{ENV["ARTIFACTORY_REPO_URL"]}/#{name}/#{name}-#{version}.tar.gz", extract: :lax_tar, |
48 | 52 | authorization: "X-JFrog-Art-Api:#{ENV["ARTIFACTORY_TOKEN"]}" |
49 | 53 | end |
| 54 | +version("3.2.6") { source sha256: "89681a9ddaa9ed7cf25ea8ef61338db805200bae47d00510490623547380c148" } |
| 55 | +version("3.2.4") { source sha256: "b23ad7fd9f73e43ad1767e636040e88ba7c9e5775bfa5618436a0dd2c17c3716" } |
| 56 | +version("3.3.3") { source sha256: "712590fd20aaa60ec75d778fe5b810d6b829ca7fb1e530577917a131f9105539" } |
| 57 | +version("3.4.1") { source sha256: "002a2d6b30b58bf4bea46c43bdd96365aaf8daa6c428782aa4feee06da197df3" } |
| 58 | +version("3.4.4") { source sha256: "7bdf55ac20f2779e99e5eca306f824fad2b37dee5a06cc35ed5a8b85a6060010" } |
| 59 | +version("3.6.0") { source sha256: "b6a5f44b7eb69e3fa35dbf15524405b44837a481d43d81daddde3ff21fcbb8e9" } |
50 | 60 |
|
| 61 | +version("3.1.2") { source sha256: "a0ce69b8b97ea6a35b96875235aa453b966ba3cba8af2de23657d8b6767d6539" } # FIPS validated |
| 62 | + |
| 63 | +version("3.0.15") { source sha256: "23c666d0edf20f14249b3d8f0368acaee9ab585b09e1de82107c66e1f3ec9533" } |
| 64 | +version("3.0.12") { source sha256: "f93c9e8edde5e9166119de31755fc87b4aa34863662f67ddfcba14d0b6b69b61" } |
| 65 | +version("3.0.11") { source sha256: "b3425d3bb4a2218d0697eb41f7fc0cdede016ed19ca49d168b78e8d947887f55" } |
| 66 | +version("3.0.9") { source sha256: "eb1ab04781474360f77c318ab89d8c5a03abc38e63d65a603cabbf1b00a1dc90" } # FIPS validated |
51 | 67 | version("3.0.5") { source sha256: "aa7d8d9bef71ad6525c55ba11e5f4397889ce49c2c9349dcea6d3e4f0b024a7a" } |
52 | 68 | version("3.0.4") { source sha256: "2831843e9a668a0ab478e7020ad63d2d65e51f72977472dc73efcefbafc0c00f" } |
53 | 69 | version("3.0.3") { source sha256: "ee0078adcef1de5f003c62c80cc96527721609c6f3bb42b7795df31f8b558c0b" } |
|
72 | 88 |
|
73 | 89 | build do |
74 | 90 | env = with_standard_compiler_flags(with_embedded_path) |
| 91 | + |
75 | 92 | if aix? |
76 | 93 | env["M4"] = "/opt/freeware/bin/m4" |
77 | 94 | elsif mac_os_x? && arm? |
|
94 | 111 | "no-idea", |
95 | 112 | "no-mdc2", |
96 | 113 | "no-rc5", |
97 | | - "no-ssl2", |
98 | 114 | "no-ssl3", |
99 | 115 | "no-zlib", |
100 | 116 | "shared", |
101 | 117 | ] |
102 | 118 |
|
| 119 | + # no-ssl2 is only valid for OpenSSL < 3.0; SSLv2 was fully removed in 3.x |
| 120 | + configure_args << "no-ssl2" if version.satisfies?("< 3.0.0") |
| 121 | + |
103 | 122 | configure_args += ["--libdir=#{install_dir}/embedded/lib"] if version.satisfies?(">=3.0.1") |
104 | 123 |
|
| 124 | + # OpenSSL >= 3.2 uses C99 syntax and may generate assembly that requires |
| 125 | + # binutils >= 2.22. Detect the assembler version at build time and disable |
| 126 | + # asm if it's too old. Also ensure C99 mode for old GCC. |
| 127 | + if version.satisfies?(">= 3.2.0") && linux? |
| 128 | + env["CFLAGS"] << " -std=gnu99" |
| 129 | + end |
| 130 | + |
105 | 131 | # https://www.openssl.org/blog/blog/2021/09/13/LetsEncryptRootCertExpire/ |
106 | 132 | configure_args += [ "-DOPENSSL_TRUSTED_FIRST_DEFAULT" ] if version.satisfies?(">= 1.0.2zb") && version.satisfies?("< 1.1.0") |
107 | 133 |
|
108 | 134 | if version.satisfies?("< 3.0.0") |
109 | 135 | configure_args += ["--with-fipsdir=#{install_dir}/embedded", "fips"] if fips_mode? |
110 | 136 | else |
111 | | - configure_args += ["-enable-fips"] if fips_mode? |
| 137 | + configure_args += ["enable-fips"] if fips_mode? |
112 | 138 | end |
113 | 139 |
|
114 | 140 | configure_cmd = |
|
128 | 154 | "./Configure #{platform} -static-libgcc" |
129 | 155 | end |
130 | 156 | elsif windows? |
131 | | - platform = windows_arch_i386? ? "mingw" : "mingw64" |
| 157 | + platform = "mingw64" |
132 | 158 | "perl.exe ./Configure #{platform}" |
133 | 159 | else |
134 | 160 | prefix = |
|
159 | 185 | patch source: "openssl-1.0.1f-do-not-build-docs.patch", env: patch_env |
160 | 186 | elsif version.start_with? "1.1" |
161 | 187 | patch source: "openssl-1.1.0f-do-not-install-docs.patch", env: patch_env |
162 | | - elsif version.start_with? "3.0" |
| 188 | + elsif version.start_with?("3.0") || version.start_with?("3.1") |
163 | 189 | patch source: "openssl-3.0.1-do-not-install-docs.patch", env: patch_env |
| 190 | + # Some of the algorithms which are being used are deprecated in OpenSSL3 and moved to legacy provider. |
| 191 | + # We need those algorithms for the working of chef-workstation and other packages. |
| 192 | + # This patch will enable the legacy providers! |
| 193 | + configure_args << "enable-legacy" |
| 194 | + patch source: "openssl-3.0.0-enable-legacy-provider.patch", env: patch_env |
| 195 | + elsif version.satisfies?(">= 3.2.4", "< 3.6") |
| 196 | + patch source: "openssl-3.2.4-do-not-install-docs.patch", env: patch_env |
| 197 | + configure_args << "enable-legacy" |
| 198 | + patch source: "openssl-3.2.4-enable-legacy-provider.patch", env: patch_env |
| 199 | + elsif version.satisfies?(">= 3.6.0") |
| 200 | + patch source: "openssl-3.6.0-do-not-install-docs.patch", env: patch_env |
| 201 | + configure_args << "enable-legacy" |
| 202 | + patch source: "openssl-3.2.4-enable-legacy-provider.patch", env: patch_env |
164 | 203 | end |
165 | 204 |
|
166 | 205 | if version.start_with?("1.0.2") && mac_os_x? && arm? |
|
172 | 211 | patch source: "openssl-1.0.1q-fix-compiler-flags-table-for-msys.patch", env: env |
173 | 212 | end |
174 | 213 |
|
| 214 | + # OpenSSL >= 3.2 requires additional Perl modules (IPC::Cmd, Time::Piece, etc.) |
| 215 | + # that may not be present on older systems like CentOS 6. |
| 216 | + if version.satisfies?(">= 3.2.0") |
| 217 | + if windows? |
| 218 | + command "perl.exe -MIPC::Cmd -e 1 2>nul || cpan IPC::Cmd", env: env |
| 219 | + command "perl.exe -MTime::Piece -e 1 2>nul || cpan Time::Piece", env: env |
| 220 | + else |
| 221 | + command "perl -MIPC::Cmd -e 1 2>/dev/null || " \ |
| 222 | + "sudo yum install -y perl-IPC-Cmd 2>/dev/null || " \ |
| 223 | + "sudo apt-get install -y libipc-cmd-perl 2>/dev/null || " \ |
| 224 | + "cpan -T IPC::Cmd", env: env |
| 225 | + command "perl -MTime::Piece -e 1 2>/dev/null || " \ |
| 226 | + "sudo yum install -y perl-Time-Piece 2>/dev/null || " \ |
| 227 | + "sudo apt-get install -y libtime-piece-perl 2>/dev/null || " \ |
| 228 | + "cpan -T Time::Piece", env: env |
| 229 | + end |
| 230 | + end |
| 231 | + |
175 | 232 | # Out of abundance of caution, we put the feature flags first and then |
176 | 233 | # the crazy platform specific compiler flags at the end. |
177 | 234 | configure_args << env["CFLAGS"] |
178 | 235 |
|
179 | | - configure_command = configure_args.unshift(configure_cmd).join(" ") |
| 236 | + # Detect old assembler at build time and add no-asm if needed. |
| 237 | + # Also disable asm on 32-bit hosts where OpenSSL's generated assembly |
| 238 | + # may use instructions unsupported by the target architecture. |
| 239 | + # block runs at build time (not parse time), so shellout hits the actual build host. |
| 240 | + block "Check assembler and libatomic" do |
| 241 | + if version.satisfies?(">= 3.2.0") && linux? |
| 242 | + is_32bit = shellout("getconf LONG_BIT 2>/dev/null").stdout.strip == "32" |
| 243 | + as_output = shellout("as --version 2>/dev/null").stdout |
| 244 | + as_ver = as_output.match(/(\d+\.\d+)/) |
| 245 | + if is_32bit || as_ver.nil? || Gem::Version.new(as_ver[1]) < Gem::Version.new("2.22") |
| 246 | + configure_args << "no-asm" |
| 247 | + end |
| 248 | + end |
| 249 | + end |
180 | 250 |
|
181 | | - command configure_command, env: env, in_msys_bash: true |
| 251 | + # block above mutates configure_args before this runs. |
| 252 | + # In omnibus, block and command are both queued build steps executed in order. |
| 253 | + block "Run Configure" do |
| 254 | + configure_command = configure_args.unshift(configure_cmd).join(" ") |
| 255 | + shellout!(configure_command, env: env, cwd: project_dir) |
| 256 | + end |
182 | 257 |
|
183 | 258 | if version.start_with?("1.0.2") && windows? |
184 | 259 | patch source: "openssl-1.0.1j-windows-relocate-dll.patch", env: env |
185 | 260 | end |
186 | 261 |
|
187 | | - make "depend", env: env |
| 262 | + # make depend is only needed for OpenSSL < 3.0; removed in 3.x |
| 263 | + make "depend", env: env if version.satisfies?("< 3.0.0") |
188 | 264 | # make -j N on openssl is not reliable |
189 | 265 | make env: env |
190 | 266 | if aix? |
|
197 | 273 | # Bug Ref: http://rt.openssl.org/Ticket/Display.html?id=2986&user=guest&pass=guest |
198 | 274 | command "sudo /usr/sbin/slibclean", env: env |
199 | 275 | end |
| 276 | + |
200 | 277 | make "install", env: env |
| 278 | + |
| 279 | + if fips_mode? && version.satisfies?(">= 3.0.0") |
| 280 | + openssl_fips_version = project.overrides.dig(:openssl, :fips_version) || "3.0.9" |
| 281 | + |
| 282 | + # Downloading the openssl-3.0.9.tar.gz file and extracting it |
| 283 | + command "wget https://www.openssl.org/source/openssl-#{openssl_fips_version}.tar.gz" |
| 284 | + command "tar -xf openssl-#{openssl_fips_version}.tar.gz" |
| 285 | + |
| 286 | + # Configuring the fips provider |
| 287 | + if windows? |
| 288 | + platform = windows_arch_i386? ? "mingw" : "mingw64" |
| 289 | + command "cd openssl-#{openssl_fips_version} && perl.exe Configure #{platform} enable-fips" |
| 290 | + else |
| 291 | + command "cd openssl-#{openssl_fips_version} && ./Configure enable-fips" |
| 292 | + end |
| 293 | + |
| 294 | + # Building the fips provider |
| 295 | + command "cd openssl-#{openssl_fips_version} && make" |
| 296 | + |
| 297 | + fips_provider_path = "#{install_dir}/embedded/lib/ossl-modules/fips.#{windows? ? "dll" : "so"}" |
| 298 | + fips_cnf_file = "#{install_dir}/embedded/ssl/fipsmodule.cnf" |
| 299 | + |
| 300 | + # Running the `openssl fipsinstall -out fipsmodule.cnf -module fips.so` command |
| 301 | + command "#{install_dir}/embedded/bin/openssl fipsinstall -out #{fips_cnf_file} -module #{fips_provider_path}" |
| 302 | + |
| 303 | + # Copying the fips provider and fipsmodule.cnf file to the embedded directory |
| 304 | + command "cp openssl-#{openssl_fips_version}/providers/fips.#{windows? ? "dll" : "so"} #{install_dir}/embedded/lib/ossl-modules/" |
| 305 | + command "cp openssl-#{openssl_fips_version}/providers/fipsmodule.cnf #{install_dir}/embedded/ssl/" |
| 306 | + |
| 307 | + # Updating the openssl.cnf file to enable the fips provider |
| 308 | + command "sed -i -e 's|# .include fipsmodule.cnf|.include #{fips_cnf_file}|g' #{install_dir}/embedded/ssl/openssl.cnf" |
| 309 | + command "sed -i -e 's|# fips = fips_sect|fips = fips_sect|g' #{install_dir}/embedded/ssl/openssl.cnf" |
| 310 | + |
| 311 | + command "#{install_dir}/embedded/bin/openssl list -providers" |
| 312 | + end |
201 | 313 | end |
0 commit comments