swifter icon indicating copy to clipboard operation
swifter copied to clipboard

SSL support

Open viktorasl opened this issue 4 years ago • 18 comments

Motivation

To have SSL support and be able to use HTTPS. The use cases of swifter library will be much broader. Our company use swifter to run mock API server in iOS UI tests (https://github.com/treatwell/twuitests), but currently arbitrary loads have to be enabled in iOS app because iOS enforces using SSL connections.

What's in this PR

This PR introduces SSL support using TLS session on Darwin OS (if everything will turn out fine I'll try adding support for Linux OS as well).

Demo optional localhost (if appears at ~/.swifter/localhost.p12) certificate loading is added to SwifterSampleOSX target.

Closes #111 #395

How did I test it?

Using mkcert tool:

mkcert -install
mkcert -pkcs12 localhost 127.0.0.1 ::1

and then imported generated .p12 file to System keychain.

viktorasl avatar Aug 02 '19 07:08 viktorasl

1 Error
:no_entry_sign: Please include a CHANGELOG entry. You can find it at CHANGELOG.md.
2 Warnings
:warning: It seems like you’ve added new tests to the library. If that’s the case, please update the XCTestManifests.swift file running in your terminal the command swift test --generate-linuxmain.
:warning: If you ran the command swift test --generate-linuxmain in your terminal, please remove the line testCase(IOSafetyTests.__allTests__IOSafetyTests), from public func __allTests() -> [XCTestCaseEntry] in the bottom of the file. For more reference see #366.
1 Message
:book: Hey, @viktorasl 👋.

Generated by :no_entry_sign: Danger

swifter-bot avatar Aug 02 '19 07:08 swifter-bot

Hey, @viktorasl Thanks for taking the time to create this. I'll try to check your PR during this week, can you please in the meantime fix the issues with Danger? Thanks.

Vkt0r avatar Aug 05 '19 00:08 Vkt0r

I'll be reviewing more soon and I'll try to test it locally with the certificates also.

Vkt0r avatar Aug 22 '19 21:08 Vkt0r

I'll probably fix everything after more thorough reviews.

viktorasl avatar Aug 23 '19 05:08 viktorasl

Sure, please let me know to continue with the review as it's a little long.

Vkt0r avatar Aug 29 '19 14:08 Vkt0r

@viktorasl Are you still interested in this PR? Please continue with the rest of the changes to be able to continue reviewing it 🙂.

Vkt0r avatar Sep 26 '19 15:09 Vkt0r

Hm, miscommunication happened. I was about to apply changes after your full review. But as I understand that I should apply changes now. I'll do that.

viktorasl avatar Sep 27 '19 06:09 viktorasl

Ups yes it was sorry about that ☹️. Sounds good please apply the changes in order to continue. Thanks again for your PR!

Vkt0r avatar Sep 27 '19 14:09 Vkt0r

Any news around this? It would be really nice when SSL support is added soon.

MartyCatawiki avatar Oct 24 '19 12:10 MartyCatawiki

@MartyCatawiki @viktorasl I would be reviewing the latest changes ASAP. Sorry for the delay 😞.

Vkt0r avatar Oct 24 '19 15:10 Vkt0r

Sorry it took me so long. Fixed according to comments, please check it out

viktorasl avatar Oct 26 '19 10:10 viktorasl

@viktorasl I'll during the week! Thanks for the heads up.

Vkt0r avatar Oct 29 '19 03:10 Vkt0r

@viktorasl Can you please compile your PR with Xcode 11.1. I'm getting errors trying to compile it in order to continue the review. Thanks.

Vkt0r avatar Nov 05 '19 04:11 Vkt0r

@viktorasl Can you please compile your PR with Xcode 11.1. I'm getting errors trying to compile it in order to continue the review. Thanks.

Found the issue regarding force cast and added swiftlint rule ignore for that one particular line. Hope it solves the problem.

viktorasl avatar Nov 05 '19 11:11 viktorasl

@viktorasl Hi! Could we use this functionality on iOS? Maybe you can add some examples and instructions to the SwifterSampleiOS? Hope to see this pull request merged :)

ismetanin avatar Dec 22 '19 14:12 ismetanin

@viktorasl Hi! Could we use this functionality on iOS? Maybe you can add some examples and instructions to the SwifterSampleiOS? Hope to see this pull request merged :)

I can look into that 👍 not sure if all APIs are supported on iOS.

viktorasl avatar Dec 23 '19 07:12 viktorasl

Hey @viktorasl Have you had time to take a look at that? I tried to run it on iOS but I had some problems with certificates probably or not - anyway I couldn't make it work on iOS

ismetanin avatar Jan 15 '20 09:01 ismetanin

Hi guys, any update on this feature?

alinmuntean avatar Jul 06 '21 08:07 alinmuntean

hei, it's that any update for this?

linhaosunny avatar Jun 14 '24 07:06 linhaosunny

@viktorasl this fork commit use ssl can't send data over 16384 bytes,

linhaosunny avatar Jun 19 '24 10:06 linhaosunny