Kitura / Kitura/SwiftyRequest

Client certificate support is broken

Open
#62 1 comment 0 reactions 1 assignee Claimed by @adam-rocska View on GitHub
Dominant language
Swift
Stars
110
Forks
18
PR merge metrics
No merged PRs in 30d

Description

Support for client certificate authentication (2-way SSL) was supposedly introduced in #33, but I believe it is broken. There is a test for this, but the test does not access an endpoint that requests a client certificate.

There are obvious errors in the code which mean it won't work. For example:
https://github.com/IBM-Swift/SwiftyRequest/blob/master/Sources/SwiftyRequest/RestRequest.swift#L930
```swift
// Read the certificate data from disk
if let key = NSData(base64Encoded: path) {
```
At first glance this looks reasonable, but `NSData(base64Encoded:)` tries to base64decode a String, it does _not_ read from a file. This will fail, because it's being provided a file path and not its contents.

Also, if it _were_ given the content of the file, there is no file format that you could straight decode as base64 - as I understand it, raw DER is binary data, and PEM is base64-encoded DER plus some human-readable headers. We'd need to remove those headers to decode the data. I'm not convinced that the code within this block has ever been executed, however it looks convincing (speaking as someone who doesn't understand it), so it may have come from somewhere authoritative, and may work if the problems above are addressed.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.