pact-foundation / pact-support

Shared code for Pact gems
MIT License
7 stars 47 forks source link

Unable to load pacts from broker with self-signed certs #88

Closed eiriarte-mendez closed 3 months ago

eiriarte-mendez commented 3 years ago

Pre issue-raising checklist

I have already (please mark the applicable with an x):

Software versions

Expected behaviour

When loading pacts from pact-broker with self signed certificates, it should not throw an error.

Actual behaviour

Tests are failing while pacts tries to load pacts from broker with self-signed certificate. Its not possible to get the certificate at the moment and there is no configuration option to disable verification.

Steps to reproduce

Relevant log files

vendor/bin/phpunit --testsuite PactProvider
PHPUnit 9.5.0 by Sebastian Bergmann and contributors.

[2021-02-25T17:41:32.167363+00:00] server.DEBUG: Starting [] []
[2021-02-25T17:41:32.202235+00:00] server.WARNING: Running in production with assertions enabled is not recommended; it has a negative impacton performance. Disable assertions in php.ini (zend.assertions = -1) for best performance or set the debug mode option to hide this warning. [] []
[2021-02-25T17:41:32.205985+00:00] server.WARNING: The 'xdebug' extension is loaded, which has a major impact on performance. [] []
[2021-02-25T17:41:32.265809+00:00] server.DEBUG: Started [] []
[2021-02-25T17:41:32.267542+00:00] server.INFO: Listening on http://127.0.0.1:6153/ [] []
"/project/vendor/pact-foundation/pact-php/src/PhpPact/Standalone/Installer/../../../../pact/bin/pact-provider-verifier https://pact.ci.ratepay.local/pacts/provider/MerchantApiActivationEventProvider/consumer/SaraConsumer/version/3.1.0 --provider-base-url=http://127.0.0.1:6153 --provider-app-version=0.0.0_alpha --publish-verification-results --verbose"
[2021-02-25T17:43:17.443589+00:00] server.WARNING: Error reading file from https://pact.ci.ratepay.local/pacts/provider/MerchantApiActivationEventProvider/consumer/SaraConsumer/version/3.1.0
SSL_connect returned=1 errno=0 state=error: certificate verify failed /project/vendor/pact-foundation/pact-php/pact/lib/ruby/lib/ruby/2.2.0/net/http.rb:923:in `connect'
/project/vendor/pact-foundation/pact-php/pact/lib/ruby/lib/ruby/2.2.0/net/http.rb:923:in `block in connect'
/project/vendor/pact-foundation/pact-php/pact/lib/ruby/lib/ruby/2.2.0/timeout.rb:74:in `timeout'
/project/vendor/pact-foundation/pact-php/pact/lib/ruby/lib/ruby/2.2.0/net/http.rb:923:in `connect'
/project/vendor/pact-foundation/pact-php/pact/lib/ruby/lib/ruby/2.2.0/net/http.rb:863:in `do_start'
/project/vendor/pact-foundation/pact-php/pact/lib/ruby/lib/ruby/2.2.0/net/http.rb:852:in `start'
/project/vendor/pact-foundation/pact-php/pact/lib/vendor/ruby/2.2.0/gems/pact-support-1.16.3/lib/pact/consumer_contract/pact_file.rb:114:in `perform_http_request'
/project/vendor/pact-foundation/pact-php/pact/lib/vendor/ruby/2.2.0/gems/pact-support-1.16.3/lib/pact/consumer_contract/pact_file.rb:85:in `get_remote'
/project/vendor/pact-foundation/pact-php/pact/lib/vendor/ruby/2.2.0/gems/pact-support-1.16.3/lib/pact/consumer_contract/pact_file.rb:62:in `block in get_remote_with_retry'
/project/vendor/pact-foundation/pact-php/pact/lib/vendor/ruby/2.2.0/gems/pact-support-1.16.3/lib/pact/consumer_contract/pact_file.rb:60:in `times'
/project/vendor/pact-foundation/pact-php/pact/lib/vendor/ruby/2.2.0/gems/pact-support-1.16.3/lib/pact/consumer_contract/pact_file.rb:60:in `get_remote_with_retry'
/project/vendor/pact-foundation/pact-php/pact/lib/vendor/ruby/2.2.0/gems/pact-support-1.16.3/lib/pact/consumer_contract/pact_file.rb:41:in `render_pact'
/project/vendor/pact-foundation/pact-php/pact/lib/vendor/ruby/2.2.0/gems/pact-support-1.16.3/lib/pact/consumer_contract/pact_file.rb:22:in `read'
/project/vendor/pact-foundation/pact-php/pact/lib/vendor/ruby/2.2.0/gems/pact-1.55.6/lib/pact/provider/pact_source.rb:17:in `pact_json'
/project/vendor/pact-foundation/pact-php/pact/lib/vendor/ruby/2.2.0/gems/pact-1.55.6/lib/pact/provider/pact_spec_runner.rb:122:in `collect'
/project/vendor/pact-foundation/pact-php/pact/lib/vendor/ruby/2.2.0/gems/pact-1.55.6/lib/pact/provider/pact_spec_runner.rb:122:in `pact_jsons'
/project/vendor/pact-foundation/pact-php/pact/lib/vendor/ruby/2.2.0/gems/pact-1.55.6/lib/pact/provider/pact_spec_runner.rb:79:in `configure_rspec'
/project/vendor/pact-foundation/pact-php/pact/lib/vendor/ruby/2.2.0/gems/pact-1.55.6/lib/pact/provider/pact_spec_runner.rb:33:in `run'
/project/vendor/pact-foundation/pact-php/pact/lib/vendor/ruby/2.2.0/gems/pact-1.55.6/lib/pact/cli/run_pact_verification.rb:70:in `run_with_pact_uri_object'
/project/vendor/pact-foundation/pact-php/pact/lib/vendor/ruby/2.2.0/gems/pact-1.55.6/lib/pact/cli/run_pact_verification.rb:51:in `run_specs'
/project/vendor/pact-foundation/pact-php/pact/lib/vendor/ruby/2.2.0/gems/pact-1.55.6/lib/pact/cli/run_pact_verification.rb:21:in `call'
/project/vendor/pact-foundation/pact-php/pact/lib/vendor/ruby/2.2.0/gems/pact-1.55.6/lib/pact/cli/run_pact_verification.rb:13:in `call'
/project/vendor/pact-foundation/pact-php/pact/lib/vendor/ruby/2.2.0/gems/pact-provider-verifier-1.32.1/lib/pact/provider_verifier/app.rb:171:in `verify_pact'
/project/vendor/pact-foundation/pact-php/pact/lib/vendor/ruby/2.2.0/gems/pact-provider-verifier-1.32.1/lib/pact/provider_verifier/app.rb:43:in `block in call'
/project/vendor/pact-foundation/pact-php/pact/lib/vendor/ruby/2.2.0/gems/pact-provider-verifier-1.32.1/lib/pact/provider_verifier/app.rb:42:in `collect'
/project/vendor/pact-foundation/pact-php/pact/lib/vendor/ruby/2.2.0/gems/pact-provider-verifier-1.32.1/lib/pact/provider_verifier/app.rb:42:in `call'
/project/vendor/pact-foundation/pact-php/pact/lib/vendor/ruby/2.2.0/gems/pact-provider-verifier-1.32.1/lib/pact/provider_verifier/app.rb:34:in `call'
/project/vendor/pact-foundation/pact-php/pact/lib/vendor/ruby/2.2.0/gems/pact-provider-verifier-1.32.1/lib/pact/provider_verifier/cli/verify.rb:47:in `verify'
/project/vendor/pact-foundation/pact-php/pact/lib/vendor/ruby/2.2.0/gems/thor-0.20.3/lib/thor/command.rb:27:in `run'
/project/vendor/pact-foundation/pact-php/pact/lib/vendor/ruby/2.2.0/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command'
/project/vendor/pact-foundation/pact-php/pact/lib/vendor/ruby/2.2.0/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch'
/project/vendor/pact-foundation/pact-php/pact/lib/vendor/ruby/2.2.0/gems/thor-0.20.3/lib/thor/base.rb:466:in `start'
/project/vendor/pact-foundation/pact-php/pact/lib/vendor/ruby/2.2.0/gems/pact-provider-verifier-1.32.1/lib/pact/provider_verifier/cli/custom_thor.rb:17:in `start'
/project/vendor/pact-foundation/pact-php/pact/lib/app/pact-provider-verifier.rb:33:in `<main>'
/project/vendor/pact-foundation/pact-php/pact/lib/ruby/lib/ruby/2.2.0/net/http.rb:923:in `connect': SSL_connect returned=1 errno=0 state=error: certificate verify failed (OpenSSL::SSL::SSLError)
        from /project/vendor/pact-foundation/pact-php/pact/lib/ruby/lib/ruby/2.2.0/net/http.rb:923:in `block in connect'
        from /project/vendor/pact-foundation/pact-php/pact/lib/ruby/lib/ruby/2.2.0/timeout.rb:74:in `timeout'
        from /project/vendor/pact-foundation/pact-php/pact/lib/ruby/lib/ruby/2.2.0/net/http.rb:923:in `connect'
        from /project/vendor/pact-foundation/pact-php/pact/lib/ruby/lib/ruby/2.2.0/net/http.rb:863:in `do_start'
        from /project/vendor/pact-foundation/pact-php/pact/lib/ruby/lib/ruby/2.2.0/net/http.rb:852:in `start'
        from /project/vendor/pact-foundation/pact-php/pact/lib/vendor/ruby/2.2.0/gems/pact-support-1.16.3/lib/pact/consumer_contract/pact_file.rb:114:in `perform_http_request'
        from /project/vendor/pact-foundation/pact-php/pact/lib/vendor/ruby/2.2.0/gems/pact-support-1.16.3/lib/pact/consumer_contract/pact_file.rb:85:in `get_remote'
        from /project/vendor/pact-foundation/pact-php/pact/lib/vendor/ruby/2.2.0/gems/pact-support-1.16.3/lib/pact/consumer_contract/pact_file.rb:62:in `block in get_remote_with_retry'
        from /project/vendor/pact-foundation/pact-php/pact/lib/vendor/ruby/2.2.0/gems/pact-support-1.16.3/lib/pact/consumer_contract/pact_file.rb:60:in `times'
        from /project/vendor/pact-foundation/pact-php/pact/lib/vendor/ruby/2.2.0/gems/pact-support-1.16.3/lib/pact/consumer_contract/pact_file.rb:60:in `get_remote_with_retry'
        from /project/vendor/pact-foundation/pact-php/pact/lib/vendor/ruby/2.2.0/gems/pact-support-1.16.3/lib/pact/consumer_contract/pact_file.rb:41:in `render_pact'
        from /project/vendor/pact-foundation/pact-php/pact/lib/vendor/ruby/2.2.0/gems/pact-support-1.16.3/lib/pact/consumer_contract/pact_file.rb:22:in `read'
        from /project/vendor/pact-foundation/pact-php/pact/lib/vendor/ruby/2.2.0/gems/pact-1.55.6/lib/pact/provider/pact_source.rb:17:in `pact_json'
        from /project/vendor/pact-foundation/pact-php/pact/lib/vendor/ruby/2.2.0/gems/pact-1.55.6/lib/pact/provider/pact_spec_runner.rb:122:in `collect'
        from /project/vendor/pact-foundation/pact-php/pact/lib/vendor/ruby/2.2.0/gems/pact-1.55.6/lib/pact/provider/pact_spec_runner.rb:122:in `pact_jsons'
        from /project/vendor/pact-foundation/pact-php/pact/lib/vendor/ruby/2.2.0/gems/pact-1.55.6/lib/pact/provider/pact_spec_runner.rb:79:in `configure_rspec'
        from /project/vendor/pact-foundation/pact-php/pact/lib/vendor/ruby/2.2.0/gems/pact-1.55.6/lib/pact/provider/pact_spec_runner.rb:33:in `run'
        from /project/vendor/pact-foundation/pact-php/pact/lib/vendor/ruby/2.2.0/gems/pact-1.55.6/lib/pact/cli/run_pact_verification.rb:70:in `run_with_pact_uri_object'
        from /project/vendor/pact-foundation/pact-php/pact/lib/vendor/ruby/2.2.0/gems/pact-1.55.6/lib/pact/cli/run_pact_verification.rb:51:in `run_specs'
        from /project/vendor/pact-foundation/pact-php/pact/lib/vendor/ruby/2.2.0/gems/pact-1.55.6/lib/pact/cli/run_pact_verification.rb:21:in `call'
        from /project/vendor/pact-foundation/pact-php/pact/lib/vendor/ruby/2.2.0/gems/pact-1.55.6/lib/pact/cli/run_pact_verification.rb:13:in `call'
        from /project/vendor/pact-foundation/pact-php/pact/lib/vendor/ruby/2.2.0/gems/pact-provider-verifier-1.32.1/lib/pact/provider_verifier/app.rb:171:in `verify_pa [] []

Tests\Contract\Provider\ActivationMessageProviderTest
  ⚈ it should verify activation message contract from sara [120.282s]

Time: 02:00.438, Memory: 22.00 MB

There was 1 error:

1) Tests\Contract\Provider\ActivationMessageProviderTest::it_should_verify_activation_message_contract_from_sara
Exception: Pact failed to validate.  Exit code: 1

/project/vendor/pact-foundation/pact-php/src/PhpPact/Provider/MessageVerifier.php:222
/project/vendor/amphp/amp/lib/Coroutine.php:118
/project/vendor/amphp/amp/lib/Internal/Placeholder.php:149
/project/vendor/amphp/amp/lib/Deferred.php:52
/project/vendor/amphp/byte-stream/lib/ResourceInputStream.php:109
/project/vendor/amphp/amp/lib/Loop/Driver.php:119
/project/vendor/amphp/amp/lib/Loop/Driver.php:72
/project/vendor/amphp/amp/lib/Loop.php:95
/project/vendor/pact-foundation/pact-php/src/PhpPact/Provider/MessageVerifier.php:229
/project/vendor/pact-foundation/pact-php/src/PhpPact/Standalone/ProviderVerifier/Verifier.php:195
/project/tests/Contract/Provider/ActivationMessageProviderTest.php:63

ERRORS!
Tests: 1, Assertions: 0, Errors: 1.
make: *** [ci_contract_test] Error 2
YOU54F commented 3 months ago

pact-php has now been upgraded, to leverage pact-reference core via ffi in pact-php 10.x beta.

For our OP, there issue was solved by the comment here regarding FF providing single line certs

https://github.com/pact-foundation/pact-support/pull/89#issuecomment-792254490

if anyone else is encountering issues, please let us know in a separate issue