33class PortableOpenssl < PortableFormula
44 desc "SSL/TLS cryptography library"
55 homepage "https://openssl.org/"
6- url "https://www.openssl.org/source/openssl-1 .1.1w .tar.gz"
7- mirror "https://www.mirrorservice.org/sites/ftp.openssl.org/source/openssl-1 .1.1w .tar.gz"
8- mirror "https://www.openssl.org/source/old/1.1.1 /openssl-1 .1.1w .tar.gz"
9- sha256 "cf3098950cb4d853ad95c0841f1f9c6d3dc102dccfcacd521d93925208b76ac8 "
10- license "OpenSSL "
6+ url "https://www.openssl.org/source/openssl-3 .1.4 .tar.gz"
7+ mirror "https://www.mirrorservice.org/sites/ftp.openssl.org/source/openssl-3 .1.4 .tar.gz"
8+ mirror "https://www.openssl.org/source/old/3.1 /openssl-3 .1.4 .tar.gz"
9+ sha256 "840af5366ab9b522bde525826be3ef0fb0af81c6a9ebd84caa600fea1731eee3 "
10+ license "Apache-2.0 "
1111
1212 resource "cacert" do
1313 # https://curl.se/docs/caextract.html
@@ -41,6 +41,9 @@ def configure_args
4141 %W[
4242 --prefix=#{ prefix }
4343 --openssldir=#{ openssldir }
44+ --libdir=#{ lib }
45+ no-legacy
46+ no-module
4447 no-shared
4548 ]
4649 end
@@ -51,11 +54,12 @@ def install
5154 # We however don't want to touch _other_ OpenSSL usages, so we change the variable name to differ.
5255 inreplace "include/internal/cryptlib.h" , "\" SSL_CERT_FILE\" " , "\" PORTABLE_RUBY_SSL_CERT_FILE\" "
5356
57+ openssldir . mkpath
5458 system "perl" , "./Configure" , *( configure_args + arch_args )
5559 system "make"
5660 system "make" , "test"
5761
58- system "make" , "install_sw "
62+ system "make" , "install_dev "
5963
6064 # Ruby doesn't support passing --static to pkg-config.
6165 # Unfortunately, this means we need to modify the OpenSSL pc file.
@@ -68,12 +72,29 @@ def install
6872 end
6973
7074 test do
71- ( testpath /"testfile.txt" ) . write ( "This is a test file" )
72- expected_checksum = "e2d0fe1585a63ec6009c8016ff8dda8b17719a637405a4e23c0ff81339148249"
73- system bin /"openssl" , "dgst" , "-sha256" , "-out" , "checksum.txt" , "testfile.txt"
74- open ( "checksum.txt" ) do |f |
75- checksum = f . read ( 100 ) . split ( "=" ) . last . strip
76- assert_equal checksum , expected_checksum
77- end
75+ ( testpath /"test.c" ) . write <<~EOS
76+ #include <openssl/evp.h>
77+ #include <stdio.h>
78+ #include <string.h>
79+
80+ int main(int argc, char *argv[])
81+ {
82+ if (argc < 2)
83+ return -1;
84+
85+ unsigned char md[EVP_MAX_MD_SIZE];
86+ unsigned int size;
87+
88+ if (!EVP_Digest(argv[1], strlen(argv[1]), md, &size, EVP_sha256(), NULL))
89+ return 1;
90+
91+ for (unsigned int i = 0; i < size; i++)
92+ printf("%02x", md[i]);
93+ return 0;
94+ }
95+ EOS
96+ system ENV . cc , "test.c" , "-L#{ lib } " , "-lcrypto" , "-o" , "test"
97+ assert_equal "717ac506950da0ccb6404cdd5e7591f72018a20cbca27c8a423e9c9e5626ac61" ,
98+ shell_output ( "./test 'This is a test string'" )
7899 end
79100end
0 commit comments