Closed opuech closed 4 years ago
I don't know how to convert on windows bash your script : openssl req -x509 -out localhost.crt -keyout localhost.key \ -newkey rsa:2048 -nodes -sha256 \ -subj '/CN=localhost' -extensions EXT -days 365 -config <( \ printf "[dn]\nCN=localhost\n[req]\ndistinguished_name = dn\n[EXT]\nsubjectAltName=DNS:localhost\nkeyUsage=digitalSignature\nextendedKeyUsage=serverAuth")
It could be usefull to have exemple of powershell script :
to push consumer Pact (Ok) $res = Invoke-WebRequest -Uri "https://olivier.pact.dius.com.au/pacts/provider/Event%20API/consumer/Event%20API%20Consumer/version/1.0.0+4jvh387gj3" -Headers @{Authorization = "Bearer XXXXXXMYKEYXXXXXXXX"} -Method Put -InFile "event_api_consumer-event_api.json" -ContentType "application/json"
to extract consumer Pact file in order to put it on an available directory file for the provider
to push provider tests results (is it this file we have to push ? : pact-net\Samples\EventApi\Provider.Api.Web.Tests\bin\Debug\net46\log\pact.log
You could try using the pact-ruby-standalone (which is the underlying CLI that pact-net uses) to publish the pacts. It works on windows. https://github.com/pact-foundation/pact-ruby-standalone/releases
Another other alternative is to use the docker container https://hub.docker.com/repository/docker/pactfoundation/pact-cli
to extract consumer Pact file in order to put it on an available directory file for the provider
Can I ask why you want do you need to do this? The verifier pulls pacts from the Pact Broker directly.
Hi Olivier,
Thanks for the detailed post.
As discussed in the support ticket, I think you'll need to add the certificate from https://olivier.pact.dius.com.au (which is an AWS CA issued certificate, fairy recent) to your trust store. I'm not a Windows expert, but the following articles looks promising:
As for being able to download Pacts, as Beth noted, you are best using the verifier with the PactBroker
option (just pointed to your broker, not an individual contract) as it will automatically pull contracts, verify them, publish the results etc. etc. If you pulled the contracts down manually and verified them one by one, you won't be able to do a lot of the magic that Pact lets you do.
I'll add the PowerShell script to examples though.
You could try using the pact-ruby-standalone (which is the underlying CLI that pact-net uses) to publish the pacts. It works on windows. https://github.com/pact-foundation/pact-ruby-standalone/releases
Another other alternative is to use the docker container https://hub.docker.com/repository/docker/pactfoundation/pact-cli
to extract consumer Pact file in order to put it on an available directory file for the provider
Can I ask why you want do you need to do this? The verifier pulls pacts from the Pact Broker directly.
Because the interactions with Powershell work very well without any configuration, and because it is better for adoption to communicate about powershell than ruby with a complex configuration. My public will be a public of windows users / developers.
Hi Olivier,
Thanks for the detailed post.
As discussed in the support ticket, I think you'll need to add the certificate from https://olivier.pact.dius.com.au (which is an AWS CA issued certificate, fairy recent) to your trust store. I'm not a Windows expert, but the following articles looks promising:
- https://stackoverflow.com/a/16134586/1008568
- https://gist.github.com/luislavena/f064211759ee0f806c88
As for being able to download Pacts, as Beth noted, you are best using the verifier with the
PactBroker
option (just pointed to your broker, not an individual contract) as it will automatically pull contracts, verify them, publish the results etc. etc. If you pulled the contracts down manually and verified them one by one, you won't be able to do a lot of the magic that Pact lets you do.I'll add the PowerShell script to examples though.
Thank you Matt, What is the better way to start a ruby irb prompt with my configuration ? Start a new ruby irb prompt, and try the following:$irb>require 'open-uri'$irb>open('https://www.gmail.com')
Hi Oliver,
The Ruby that is used in pact-net is packaged along with the Pact code, so it's not using your system ruby. Running irb for your own system ruby will not allow you to reproduce any issues you might be seeing with your Pact code.
You can download the pact-ruby-standalone for windows here https://github.com/pact-foundation/pact-ruby-standalone/releases If you dig around inside the folders, you'll find an irb
executable. You can try running that. I believe it shows a few errors, it from memory, it does run.
because it is better for adoption to communicate about powershell than ruby with a complex configuration
You don't see any of the Ruby - it's all wrapped with Pact.NET, or docker command line arguments.
You're going to miss out on a lot of new features (pending pacts, wip pacts) by using the direct URLs.
It may be that the windows certificates bundled with the standalone are not working with the certificates on Pactflow - it would be strange however, because we haven't noticed any issues on any of the other platforms. Here's an issue that might be relevant. https://github.com/pact-foundation/pact-ruby-standalone/issues/30
Thanks Beth,
From 'pact-ruby-standalone', i have the same issue with
pact-provider-verifier.bat https://olivier.pact.dius.com.au/pacts/provider/Event%20API/consumer/Event%20API%20Consumer/version/1.0.0+4jvh387gj3 --provider-base-url=https://olivier.pact.dius.com.au SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed
After the execution, echo %SSL_CERT_FILE% ->C:_W\PocPact\pact\lib\ruby\bin\ ..\lib\ca-bundle.crt
From 'https://olivier.pact.dius.com.au/' with Chrome, i have downloaded the certificate 'pactflow-b64.cer' in x.509 base 64
With OpenSSL, i have executed 'openssl x509 -inform PEM -in pactflow-b64.cer -out ca-bundle.crt'
i have copied the file on C:_W\PocPact\pact\lib\ruby\bin\ ..\lib\ and C:_W\PocPact\pact\lib\ruby\lib in order to overwrite the existing one
Same error with with pact-provider-verifier.bat
Thank you for your help !
Sorry, I'm unclear, did copying the certificate file in fix it or not?
Have you tried using the c# publisher? https://github.com/pact-foundation/pact-net#using-the-c-client
Hello Beth,
I copied the certificate file and the problem still persists. Maybe a "ruby irb prompt" could help to diagnose ($irb>open('https://olivier.pact.dius.com.au'))
On Tue, May 12, 2020 at 8:22 PM Beth Skurrie notifications@github.com wrote:
Sorry, I'm unclear, did copying the certificate file in fix it or not?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/pact-foundation/pact-net/issues/242#issuecomment-627669273, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEO7PLVOD436FDNNCOVCN6LRRHR45ANCNFSM4M4HIXNQ .
Have you tried using the c# publisher? https://github.com/pact-foundation/pact-net#using-the-c-client
Publishing the pact with Powershell is ok, not with c#, not with command line tool. The best way coul be to use System.Net.Http.HttpClient for interaction with PactBroker. Is it possible ?
I think it is a windows firewall problem :
(i restarted from stratch, and i remembered that i already had this message )
Interesting. So if you can't put exclusions in for the Ruby process to publish, you're going to have to do one of a few things:
@bethesque this is going to affect the publishing of the pact and the verification results, correct?
@neilcampbell would you support a PR? @opuech has indicated he's willing to help out
I'd rather not have another completely separate publishing implementation unless we can avoid it. Can you whitelist the Ruby process?
I'd rather not have another completely separate publishing implementation unless we can avoid it. Can you whitelist the Ruby process?
I think it will be difficult (my company policy) but it is an option.
Whitelisting would be the best option, otherwise you would have a reasonable amount of work ahead of you.
The other option would be getting the Rust implementation in, and adding support for publishing and all of this stuff - that would at least be strategic, but not something that would be quick or easy.
I deployed successfully a pact-broker on a k8s cluster - http mode - no security; no problem to publish to this broker. Whitelisting the Ruby process is still an option to go further. Thank you for your help, i will close the ticket.
Hi,
Step to reproduce :
I am on Microsoft Windows 10 Enterprise
i have downloaded the github project and have compiled
i have executed with success all Consumer.tests
I have published "event_api_consumer-event_api.json" $res = Invoke-WebRequest -Uri "https://olivier.pact.dius.com.au/pacts/provider/Event%20API/consumer/Event%20API%20Consumer/version/1.0.0+4jvh387gj3" -Headers @{Authorization = "Bearer XXXXXXMYKEYXXXXXXXX"} -Method Put -InFile "event_api_consumer-event_api.json" -ContentType "application/json"
From https://github.com/pact-foundation/pact-net/blob/master/Samples/EventApi/Provider.Api.Web.Tests/EventAPITests.cs, i have updated l42 as followed : .PactBroker("https://olivier.pact.dius.com.au", uriOptions: new PactUriOptions("XXXXXXMYKEYXXXXXXXX"), consumerVersionTags: new List { "master" })
When i am executing "EnsureEventApiHonoursPactWithConsumer", i have the following error : Message: PactNet.PactFailureException : Pact verification failed. See output for details. If the output is empty please provide a custom config.Outputters (IOutput) for your test framework, as we couldn't write to the console. Stack Trace: PactCoreHost`1.Start() line 139 PactVerifier.Verify(String description, String providerState) line 170 EventApiTests.EnsureEventApiHonoursPactWithConsumer() line 38
Open additional output for this result Error making request - OpenSSL::SSL::SSLError SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed , attempt 1 of 3 Error making request - OpenSSL::SSL::SSLError SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed , attempt 2 of 3 Error making request - OpenSSL::SSL::SSLError SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed , attempt 3 of 3 C:/Users/LI2BD5/source/repos/pact-net/Samples/EventApi/Provider.Api.Web.Tests/bin/Debug/net46/pact-win32/lib/ruby/lib/ruby/2.2.0/net/http.rb:923:in
connect': SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (OpenSSL::SSL::SSLError) from C:/Users/LI2BD5/source/repos/pact-net/Samples/EventApi/Provider.Api.Web.Tests/bin/Debug/net46/pact-win32/lib/ruby/lib/ruby/2.2.0/net/http.rb:923:in
block in connect' from C:/Users/LI2BD5/source/repos/pact-net/Samples/EventApi/Provider.Api.Web.Tests/bin/Debug/net46/pact-win32/lib/ruby/lib/ruby/2.2.0/timeout.rb:74:intimeout' from C:/Users/LI2BD5/source/repos/pact-net/Samples/EventApi/Provider.Api.Web.Tests/bin/Debug/net46/pact-win32/lib/ruby/lib/ruby/2.2.0/net/http.rb:923:in
connect' from C:/Users/LI2BD5/source/repos/pact-net/Samples/EventApi/Provider.Api.Web.Tests/bin/Debug/net46/pact-win32/lib/ruby/lib/ruby/2.2.0/net/http.rb:863:indo_start' from C:/Users/LI2BD5/source/repos/pact-net/Samples/EventApi/Provider.Api.Web.Tests/bin/Debug/net46/pact-win32/lib/ruby/lib/ruby/2.2.0/net/http.rb:852:in
start' from C:/Users/LI2BD5/source/repos/pact-net/Samples/EventApi/Provider.Api.Web.Tests/bin/Debug/net46/pact-win32/lib/vendor/ruby/2.2.0/gems/pact-1.49.3/lib/pact/hal/http_client.rb:55:inblock in perform_request' from C:/Users/LI2BD5/source/repos/pact-net/Samples/EventApi/Provider.Api.Web.Tests/bin/Debug/net46/pact-win32/lib/vendor/ruby/2.2.0/gems/pact-1.49.3/lib/pact/retry.rb:23:in
until_true' from C:/Users/LI2BD5/source/repos/pact-net/Samples/EventApi/Provider.Api.Web.Tests/bin/Debug/net46/pact-win32/lib/vendor/ruby/2.2.0/gems/pact-1.49.3/lib/pact/hal/http_client.rb:49:inperform_request' from C:/Users/LI2BD5/source/repos/pact-net/Samples/EventApi/Provider.Api.Web.Tests/bin/Debug/net46/pact-win32/lib/vendor/ruby/2.2.0/gems/pact-1.49.3/lib/pact/hal/http_client.rb:24:in
get' from C:/Users/LI2BD5/source/repos/pact-net/Samples/EventApi/Provider.Api.Web.Tests/bin/Debug/net46/pact-win32/lib/vendor/ruby/2.2.0/gems/pact-1.49.3/lib/pact/hal/link.rb:49:inget' from C:/Users/LI2BD5/source/repos/pact-net/Samples/EventApi/Provider.Api.Web.Tests/bin/Debug/net46/pact-win32/lib/vendor/ruby/2.2.0/gems/pact-1.49.3/lib/pact/pact_broker/fetch_pact_uris_for_verification.rb:50:in
index' from C:/Users/LI2BD5/source/repos/pact-net/Samples/EventApi/Provider.Api.Web.Tests/bin/Debug/net46/pact-win32/lib/vendor/ruby/2.2.0/gems/pact-1.49.3/lib/pact/pact_broker/fetch_pact_uris_for_verification.rb:37:incall' from C:/Users/LI2BD5/source/repos/pact-net/Samples/EventApi/Provider.Api.Web.Tests/bin/Debug/net46/pact-win32/lib/vendor/ruby/2.2.0/gems/pact-1.49.3/lib/pact/pact_broker/fetch_pact_uris_for_verification.rb:33:in
call' from C:/Users/LI2BD5/source/repos/pact-net/Samples/EventApi/Provider.Api.Web.Tests/bin/Debug/net46/pact-win32/lib/vendor/ruby/2.2.0/gems/pact-1.49.3/lib/pact/pact_broker.rb:18:infetch_pact_uris_for_verification' from C:/Users/LI2BD5/source/repos/pact-net/Samples/EventApi/Provider.Api.Web.Tests/bin/Debug/net46/pact-win32/lib/vendor/ruby/2.2.0/gems/pact-provider-verifier-1.30.1/lib/pact/provider_verifier/aggregate_pact_configs.rb:45:in
pacts_for_verification' from C:/Users/LI2BD5/source/repos/pact-net/Samples/EventApi/Provider.Api.Web.Tests/bin/Debug/net46/pact-win32/lib/vendor/ruby/2.2.0/gems/pact-provider-verifier-1.30.1/lib/pact/provider_verifier/aggregate_pact_configs.rb:38:inpacts_urls_from_broker' from C:/Users/LI2BD5/source/repos/pact-net/Samples/EventApi/Provider.Api.Web.Tests/bin/Debug/net46/pact-win32/lib/vendor/ruby/2.2.0/gems/pact-provider-verifier-1.30.1/lib/pact/provider_verifier/aggregate_pact_configs.rb:25:in
call' from C:/Users/LI2BD5/source/repos/pact-net/Samples/EventApi/Provider.Api.Web.Tests/bin/Debug/net46/pact-win32/lib/vendor/ruby/2.2.0/gems/pact-provider-verifier-1.30.1/lib/pact/provider_verifier/aggregate_pact_configs.rb:10:incall' from C:/Users/LI2BD5/source/repos/pact-net/Samples/EventApi/Provider.Api.Web.Tests/bin/Debug/net46/pact-win32/lib/vendor/ruby/2.2.0/gems/pact-provider-verifier-1.30.1/lib/pact/provider_verifier/app.rb:197:in
all_pact_urls' from C:/Users/LI2BD5/source/repos/pact-net/Samples/EventApi/Provider.Api.Web.Tests/bin/Debug/net46/pact-win32/lib/vendor/ruby/2.2.0/gems/pact-provider-verifier-1.30.1/lib/pact/provider_verifier/app.rb:40:in `call' from C:/Users/LI2BD5/source/repos/pact-net/Samples/EventApi/Provider.Api.Web.Tests/bin/Debug/net46/pact-win32/lib/vendor/ruby/2.2.0How can i fix this issue ?
Thank you !