-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Connection Error when working with pact mock service enabling ssl #114
Comments
Have you made your In your app target where you've implemented your API client, set it to conform to public func urlSession(
_ session: URLSession,
didReceive challenge: URLAuthenticationChallenge,
completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void
) In it you can define which domains should allow insecure certificates. This will allow your API client to communicate over An example delegate method can be found here and here. Your |
Hello! Thank you very much for your answer. I've done what you suggested, but the providerMock is not using the API client I've implemented. If I run the test, but commenting the API client part, it will fail equally with the same error message, as you can see in the image below: By taking a look at PactVerificationService class, it seems it takes the API client paper when instantiated. Actually, if a put a break point in the URLSession delegate method, and run the test, and then hits the extension URLSession.APIServiceError: LocalizedError, and shows the ssl error message: I´ve uploaded the example implemented to an open repo, in case you could take a look. Perhaps I'm missing something. Thank you very much for your time. |
I can have a look once I get some time. There's something fishy going on here. Perhaps something changed in 14.4? EDIT: Out of curiosity, is there a specific reason you're testing using |
There seems to have been a change in iOS 14.x that is breaking this! When hitting Using your example project, target iOS 14.4 and Xcode 12.4: // old
challenge.protectionSpace.host.contains("localhost")
// with new
(challenge.protectionSpace.host.contains("localhost") || challenge.protectionSpace.host.contains("127.0.0.1") || challenge.protectionSpace.host.contains("0.0.0.0")) Then...
// NOT OK
let pactVerificationService = PactVerificationService(url: "https://localhost", port: 1234, allowInsecureCertificates: true)
// IS OK 🤷♂️
let pactVerificationService = PactVerificationService(url: "https://127.0.0.1", port: 1234, allowInsecureCertificates: true) // OK We will need to look into this and improve the Anyone with some time on their hand that wants to open a PR for it (solution is already up there), feel free to open it. |
Thank you very much! Replicated the changes, and now works properly! The reason we tried with v2 is because v3 is labeled as under heavy development, so we decided to aim to a more stable version, just in case. As well, v3 it is not distributed through CocoaPods, which is the dependency manager we use. If that would change, we could give a try. Regarding the PR, tried to push a branch to create the PR but got an access denied. |
Good to hear. I'm not really happy with using IP addresses instead of For the PRs on this repo you would've needed to fork it first, make changes on your fork and then open a PR from your fork back into this repository. We could update CHANGELOG.md with better guidance on how to open PRs. Fair enough regarding PactSwift and heavy development note. It should be stable enough to be used in order to raise bugs or suggestions if nothing else. This way we could get the higher level of confidence faster. |
@caferlop I have updated the PactMacOSExample project to demonstrate how to set up a few Pact tests using latest tools at our disposal (macOS 11, Xcode 12.4). There should be minimal differences in setting up a project using CocoaPods as a dependency manager I would imagine. Again, I have strong feelings about CocoaPods and haven't used it a project in about 4-5 years. The update to |
Thank you very much @surpher @andrewspinks !!! |
Just wanted to note that I was hitting a brick wall having the same issue on version 0.10.1 (macOS 11.2, Xcode 12.2). Using |
Hello!
Trying to setup a PoC for a Swift project, enabling ssl in the pact-mock-service lead us to the error message shown in the below image:
The server is launched using:
pact-mock-service start --ssl --pact-specification-version 2.0.0 --log "${SRCROOT}/tmp/pact-ssl.log" --pact-dir "${SRCROOT}/tmp/pacts-ssl" -p 1234
The PactVerificationService is instantiated allowing insecure certificates:
Yet it seems it is not to accept the self signed certificate:
Have you guys faced this kind of issue?
Thanks in advance.
The text was updated successfully, but these errors were encountered: