pact-foundation / pact-ruby-standalone

A standalone pact command line executable using the ruby pact implementation and Travelling Ruby
https://pact.io
MIT License
39 stars 32 forks source link

Revert "Revert "chore(deps): upgrade traveling-ruby to 20240205-3.3.0"" #130

Closed YOU54F closed 4 months ago

YOU54F commented 4 months ago

Reverts pact-foundation/pact-ruby-standalone#129

Updates to Ruby 3.3.0 + OpenSSL 3.2.0

Note:- pact-mock-service will now error when configured with an expired certificate

Check the cert date

openssl x509 -enddate -noout -in test/ssl/server.crt             
notAfter=Jan 21 10:45:15 2018 GMT

Start the mock service with the ssl params

standalone/darwin-arm64-2.3.0/pact/bin/pact-mock-service  --ssl --sslcert test/ssl/server.crt --sslkey test/ssl/server.key 

Output from mock server

INFO  WEBrick 1.8.1
INFO  ruby 3.2.2 (2023-03-30) [arm64-darwin22]
INFO  \nCertificate:\n    Data:\n        Version: 1 (0x0)\n        Serial Number:\n            f0:89:30:81:f3:af:b0:20\n        Signature Algorithm: sha1WithRSAEncryption\n        Issuer: C=AU, ST=Some-State, O=Internet Widgits Pty Ltd\n        Validity\n            Not Before: Jan 21 10:45:15 2017 GMT\n            Not After : Jan 21 10:45:15 2018 GMT\n        Subject: C=AU, ST=Some-State, O=Internet Widgits Pty Ltd\n        Subject Public Key Info:\n            Public Key Algorithm: rsaEncryption\n                RSA Public-Key: (1024 bit)\n                Modulus:\n                    00:aa:8d:ba:05:ef:d0:54:8a:dd:3e:84:70:26:80:\n                    b1:1d:62:57:73:68:5b:a9:61:77:90:76:d1:3b:78:\n                    5f:06:0c:be:67:3f:b2:cd:8e:db:d3:ca:60:09:45:\n                    ae:97:d9:f9:44:e9:43:22:56:7a:56:f1:4c:59:5a:\n                    b6:18:af:3b:54:1d:6a:cb:34:d8:f1:2a:5d:08:18:\n                    28:70:36:f2:f7:55:3e:a9:45:90:29:52:4f:00:b9:\n                    8b:b4:c8:d9:71:42:5a:15:99:2d:d2:02:92:ea:d7:\n                    83:98:08:2c:f9:9b:ac:10:63:49:61:9a:7b:83:d8:\n                    fb:61:18:10:be:2f:da:22:ef\n                Exponent: 65537 (0x10001)\n    Signature Algorithm: sha1WithRSAEncryption\n         08:34:0e:66:c3:60:d4:27:90:d8:67:90:ba:9f:32:e5:a7:43:\n         6b:76:3a:4b:17:6c:95:1d:5f:e4:e0:3b:ed:c0:bc:ce:f1:59:\n         d2:f7:21:0b:26:24:b3:13:47:0f:1c:44:39:e5:65:af:a4:47:\n         61:01:16:5f:7d:16:1f:a7:6c:c6:6c:28:10:4a:d5:03:7c:e9:\n         27:f0:75:fe:c5:a4:51:7d:b9:8e:94:de:2f:d4:7d:70:de:8b:\n         4c:5c:c7:1b:79:3c:78:3e:a5:66:c0:9f:34:aa:0c:bb:32:df:\n         d2:25:bf:ce:4d:1a:52:a8:ec:aa:63:2a:92:c6:cc:59:da:b7:\n         dd:12\n
INFO  WEBrick::HTTPServer#start: pid=26762 port=55701

Make a request with the cert

SSL_CERT_FILE=test/ssl/server.crt curl https://localhost:55701 

error for client

curl: (60) SSL certificate problem: certificate has expired
More details here: https://curl.se/docs/sslcerts.html

curl failed to verify the legitimacy of the server and therefore could not
establish a secure connection to it. To learn more about this situation and
how to fix it, please visit the web page mentioned above.

Error in mock server

INFO  WEBrick::HTTPServer#start: pid=26762 port=55701
ERROR OpenSSL::SSL::SSLError: SSL_accept returned=1 errno=0 peeraddr=(null) state=error: sslv3 alert certificate expired
        /Users/saf/dev/pact-foundation/pact-js-core/standalone/darwin-arm64-2.3.0/pact/lib/vendor/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/server.rb:302:in `accept'
        /Users/saf/dev/pact-foundation/pact-js-core/standalone/darwin-arm64-2.3.0/pact/lib/vendor/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/server.rb:302:in `block (2 levels) in start_thread'
        /Users/saf/dev/pact-foundation/pact-js-core/standalone/darwin-arm64-2.3.0/pact/lib/vendor/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/utils.rb:258:in `timeout'
        /Users/saf/dev/pact-foundation/pact-js-core/standalone/darwin-arm64-2.3.0/pact/lib/vendor/ruby/3.2.0/gems/webrick-1.8.1/lib/webrick/server.rb:300:in `block in start_thread'

Using a cert which is configured to expire in the future, results in a successful test run

YOU54F commented 4 months ago

Passing test runs against consumes of pact ruby standalone with 2.2.0 or 2.3.0 (which contain the packaging with Ruby 3.3.0 / OpenSSL 3.2.0 )