I'm trying to implement pact verification on provider side using pact-net v4.5.0.0 or v5.0 beta. Here is my code for this:
using var verifier = new PactVerifier();
verifier.ServiceProvider("CampaignFinder API", new Uri(PactServiceUri))
.WithPactBrokerSource(new Uri("https://pact-broker-pact.apps.ocpdoa.akbank.com"))
.WithSslVerificationDisabled()
.WithProviderStateUrl(new Uri($"{PactServiceUri}/provider-states"))
.Verify();
But it fails with this error:
1) Failed to load pact - Could not load pacts from the pact broker 'https://pact-broker-pact.apps.ocpdoa.akbank.com/'
There were 1 pact failures
Verifier Logs
-------------
2023-12-12T13:42:26.942303Z INFO ThreadId(09) pact_verifier::pact_broker: Fetching path '/' from pact broker
2023-12-12T13:42:26.974295Z WARN ThreadId(09) rustls::conn: Sending fatal alert BadCertificate
2023-12-12T13:42:26.974776Z ERROR ThreadId(09) pact_verifier: Failed to load pact - [31mCould not load pacts from the pact broker 'https://pact-broker-pact.apps.ocpdoa.akbank.com/'[0m
2023-12-12T13:42:26.974834Z WARN ThreadId(09) pact_matching::metrics:
Please note:
We are tracking events anonymously to gather important usage statistics like Pact version and operating system. To disable tracking, set the 'PACT_DO_NOT_TRACK' environment variable to 'true'.
v5.0 log does not state the root cause of the problem but I guess it is the same ssl error:
Failures:
1) Failed to load pact - Could not load pacts from the pact broker 'https://pact-broker-pact.apps.ocpdoa.akbank.com/'
There were 1 pact failures
Verifier Logs
-------------
2023-12-14T08:39:30.795018Z INFO ThreadId(09) pact_verifier::pact_broker: Fetching path '/' from pact broker
2023-12-14T08:39:30.826714Z ERROR ThreadId(09) pact_verifier: Failed to load pact - [31mCould not load pacts from the pact broker 'https://pact-broker-pact.apps.ocpdoa.akbank.com/'[0m
2023-12-14T08:39:30.826831Z WARN ThreadId(09) pact_matching::metrics:
Please note:
We are tracking events anonymously to gather important usage statistics like Pact version and operating system. To disable tracking, set the 'PACT_DO_NOT_TRACK' environment variable to 'true'.
Our pact-broker is using a self signed certiciface, I guess this is the cause of the error.
Why does .WithSslVerificationDisabled() call have no effect? When I import the certificate to my computer's trust store, I can run the test succesfully. However I'd like to disable ssl verification as this may cause problems in CI/CD.
Please advise how to disable ssl check.
There is a ffi bug. As a temporary solution, I can suggest to use a reverse-proxy in ci (for example, nginx or traefik), and in tests make a call to the proxy via http and redirect this call to https to the broker.