-
Notifications
You must be signed in to change notification settings - Fork 19
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
Certificate Pinning Verification #20
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You seem to have changed all the spaces to tabs.
Codecov Report
@@ Coverage Diff @@
## master #20 +/- ##
==========================================
- Coverage 53.12% 52.65% -0.47%
==========================================
Files 9 9
Lines 800 809 +9
==========================================
+ Hits 425 426 +1
- Misses 375 383 +8
Continue to review full report at Codecov.
|
9fc6da3
to
4b255df
Compare
Hi there, any updates on this PR? |
@ianpartridge This PR is ready for review/merging (two Travis tests appear to fail but all pass locally so could just be an anomaly). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few comments, plus there's no test yet.
Log.warning(warning) | ||
fallthrough | ||
} | ||
if let certificateData = NSData(contentsOfFile: Bundle.main.path(forResource: self.pinnedCertificateName, ofType: "der") ?? "") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we creating the NSData even if self.pinnedCertificateName is nil? Shouldn't we skip this whole section if it's nil?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a guard to ensure it's not nil.
completionHandler(.useCredential, URLCredential(trust: trust)) | ||
return | ||
} else { | ||
completionHandler(.performDefaultHandling, nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we return after this? Otherwise we'll call the completion handler twice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
|
Does it cover the certificate pinning though? |
@@ -140,6 +140,7 @@ class SwiftyRequestTests: XCTestCase { | |||
let expectation = self.expectation(description: "Data Echoed Back") | |||
|
|||
let request = RestRequest(method: .get, url: echoURLSecure, containsSelfSignedCert: true) | |||
request.pinnedCertificateName = "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please can we leave this test alone, add a new testPinnedCertificate()
and test with a real pinned certificate? Or is that not possible?
|
Verify server certificates the user is connecting to. In relation to this issue: #19