Skip to content

Commit 95a1270

Browse files
authored
Merge pull request #47 from noppoMan/static-cert-loading
Static cert loading
2 parents aca1ac3 + 9400a3d commit 95a1270

File tree

9 files changed

+24
-7571
lines changed

9 files changed

+24
-7571
lines changed

Certs/cert.pem

Lines changed: 0 additions & 21 deletions
This file was deleted.

Certs/key.pem

Lines changed: 0 additions & 28 deletions
This file was deleted.

Certs/mozilla_certs.pem

Lines changed: 0 additions & 3865 deletions
This file was deleted.

Certs/openbsd_certs.pem

Lines changed: 0 additions & 3632 deletions
This file was deleted.

Sources/Prorsum/HTTP/HTTPClient.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public class HTTPClient {
100100
}
101101

102102
if request.accept.isEmpty {
103-
request.accept = [try MediaType(string: "Accept: */*")]
103+
request.accept = [try MediaType(string: "*/*")]
104104
}
105105

106106
let serializer = RequestSerializer(stream: stream)

Sources/Prorsum/TLS/Certificate.swift

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121
//SOFTWARE.
2222

23+
2324
public enum Certificates {
2425
public enum Signature {
2526
case selfSigned
@@ -66,32 +67,12 @@ public enum Certificates {
6667
extension Certificates {
6768
@available(*, deprecated: 1.0, message: "Use `.openbsd` instead.")
6869
public static var mozilla: Certificates {
69-
let root = #file.characters
70-
.split(separator: "/", omittingEmptySubsequences: false)
71-
.dropLast(4)
72-
.map { String($0) }
73-
.joined(separator: "/")
74-
75-
return .certificateAuthority(
76-
signature: .signedFile(
77-
caCertificateFile: root + "/Certs/mozilla_certs.pem"
78-
)
79-
)
70+
return .certificateAuthority(signature: .signedBytes(caCertificateBytes: mozilla_certs_pem.bytes))
8071
}
8172
}
8273

8374
extension Certificates {
8475
public static var openbsd: Certificates {
85-
let root = #file.characters
86-
.split(separator: "/", omittingEmptySubsequences: false)
87-
.dropLast(4)
88-
.map { String($0) }
89-
.joined(separator: "/")
90-
91-
return .certificateAuthority(
92-
signature: .signedFile(
93-
caCertificateFile: root + "/Certs/openbsd_certs.pem"
94-
)
95-
)
76+
return .certificateAuthority(signature: .signedBytes(caCertificateBytes: openbsd_certs_pem.bytes))
9677
}
9778
}

Sources/Prorsum/TLS/Certs/mozilla_certs.swift

Lines changed: 9 additions & 0 deletions
Large diffs are not rendered by default.

Sources/Prorsum/TLS/Certs/openbsd_certs.swift

Lines changed: 9 additions & 0 deletions
Large diffs are not rendered by default.

Tests/ProrsumTests/HTTPClientTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ class HTTPClientTests: XCTestCase {
2828
}
2929

3030
func testConnect() {
31-
let client = try! HTTPClient(url: URL(string: "http://httpbin.org")!)
31+
let client = try! HTTPClient(url: URL(string: "http://httpbin.org/get")!)
3232
try! client.open()
3333
let response = try! client.request()
3434

3535
XCTAssertEqual(response.statusCode, 200)
3636
}
3737

3838
func testHTTPSConnect() {
39-
let client = try! HTTPClient(url: URL(string: "https://httpbin.org")!)
39+
let client = try! HTTPClient(url: URL(string: "https://httpbin.org/get")!)
4040
try! client.open()
4141
let response = try! client.request()
4242

0 commit comments

Comments
 (0)