-
Notifications
You must be signed in to change notification settings - Fork 23
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
Swift SDK does not support self-signed server certificates. #12
Comments
Thanks for opening this. For swift 4 we plan to use urlSession. I made the SDK to allow to take an override to APIHOST, by allowing the user to specify a baseURL. This allowed me to write test to pass in Travis. I production system WHISK APIHOST will always be https with valid certificates. We can leave this issue open until linux supports self sign certs, and then allow an override in the Class to skip ssl checks, but should not be the default. |
Here is an example //Overriding WHISK API HOST using baseUrl, only applicable in testing with self sign ssl certs"
Whisk.baseUrl = "http://172.17.0.1:10001"
let invokeResult = Whisk.invoke(actionNamed: "/whisk.system/utils/date", withParameters: [:], blocking: false) |
In the code above, this won't be the default behaviour. It relies on the user explictly setting a function parameter, which defaults to false. This mirrors the behaviour of the JavaScript SDK. |
Yep that correct it would no be the default. |
Sorry read your comment again, I think I missed it the first time. The default behavior for what ever reason today (ie. 3.1.1) _Whisk class API is
It would be good to have consistency with theJavaScript SDK, but I think is more important to not break people's code by changing the API when they move from swift 3 to swift4. I think it's something to note when we get to building new Library/SDK for swift4+ both client and server, and maybe a new Class |
Local instances of the platform use a self-signed SSL certificate. The Swift SDK (
_Whisk.swift
) fails when invoked against platform endpoints without a valid SSL certificate.The JavaScript SDK supports a constructor argument to turn off certificat checking to resolve this issue. Looking into implementing this behaviour for the Swift SDK, I have discovered a blocking issue due to the lack of support in the open-source Swift Foundation libraries.
In Swift, certificate checking can be turned off by creating a new
URLSessionDelegate
with always trusts the server.This can be used when creating the
URLSession
to use based upon a method parameter.This works on OS X but compiling the code on Linux, I ran into the following issue.
Looking into the source code for the Swift foundation core libraries, I discovered this method has not been implemented.
https://github.com/apple/swift-corelibs-foundation/blob/master/Foundation/URLCredential.swift#L155
Talking to the IBM@Swift team, support for this feature is being worked on but won't be available until Swift 5 at the earliest.
Until then, we will have to document the behaviour and wait for the foundation libraries to catch up. I've attached the completed
_Whisk.swift
demonstrating the bug.The text was updated successfully, but these errors were encountered: