Skip to content
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

Bump required version of NIOSSL #559

Merged
merged 1 commit into from
Aug 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
"repositoryURL": "https://github.com/apple/swift-nio.git",
"state": {
"branch": null,
"revision": "26586835fd327f754efdebe3b9869f1e6f7cc298",
"version": "2.6.1"
"revision": "790827800d6af12ca6a8b1dca7a9072606fd2a1e",
"version": "2.7.0"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ let package = Package(
// HTTP2 via SwiftNIO
.package(url: "https://github.com/apple/swift-nio-http2.git", from: "1.5.0"),
// TLS via SwiftNIO
.package(url: "https://github.com/apple/swift-nio-ssl.git", from: "2.0.0"),
.package(url: "https://github.com/apple/swift-nio-ssl.git", from: "2.4.0"),
// Support for Network.framework where possible. Note: from 1.0.2 the package
// is essentially an empty import on platforms where it isn't supported.
.package(url: "https://github.com/apple/swift-nio-transport-services.git", from: "1.0.2"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,23 @@ public struct InteroperabilityTestCredentials {

/// Self signed gRPC interoperability test CA certificate.
public static let caCertificate = try! NIOSSLCertificate(
buffer: Array(caCertificatePem.utf8CString),
bytes: .init(caCertificatePem.utf8),
format: .pem)

/// gRPC interoperability test server certificate.
///
/// Note: the specification refers to the certificate and key as "server1", this name is carried
/// across here.
public static let server1Certificate = try! NIOSSLCertificate(
buffer: Array(server1CertificatePem.utf8CString),
bytes: .init(server1CertificatePem.utf8),
format: .pem)

/// gRPC interoperability test server private key.
///
/// Note: the specification refers to the certificate and key as "server1", this name is carried
/// across here.
public static let server1Key = try! NIOSSLPrivateKey(
buffer: Array(server1KeyPem.utf8CString),
bytes: .init(server1KeyPem.utf8),
format: .pem)

private static let caCertificatePem = """
Expand Down
12 changes: 6 additions & 6 deletions Sources/GRPCPerformanceTests/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ func measure(description: String, benchmark: Benchmark, repeats: Int) -> Benchma
/// - Parameter certificatePath: The path to the certificate.
/// - Parameter privateKeyPath: The path to the private key.
/// - Parameter server: Whether this is for the server or not.
private func makeServerTLSConfiguration(caCertificatePath: String, certificatePath: String, privateKeyPath: String) -> Server.Configuration.TLS? {
private func makeServerTLSConfiguration(caCertificatePath: String, certificatePath: String, privateKeyPath: String) throws -> Server.Configuration.TLS? {
// Commander doesn't have Optional options; we use empty strings to indicate no value.
guard certificatePath.isEmpty == privateKeyPath.isEmpty &&
privateKeyPath.isEmpty == caCertificatePath.isEmpty else {
Expand All @@ -231,7 +231,7 @@ private func makeServerTLSConfiguration(caCertificatePath: String, certificatePa
}

return .init(
certificateChain: [.file(certificatePath)],
certificateChain: try NIOSSLCertificate.fromPEMFile(certificatePath).map { .certificate($0) },
privateKey: .file(privateKeyPath),
trustRoots: .file(caCertificatePath)
)
Expand All @@ -241,7 +241,7 @@ private func makeClientTLSConfiguration(
caCertificatePath: String,
certificatePath: String,
privateKeyPath: String
) -> ClientConnection.Configuration.TLS? {
) throws -> ClientConnection.Configuration.TLS? {
// Commander doesn't have Optional options; we use empty strings to indicate no value.
guard certificatePath.isEmpty == privateKeyPath.isEmpty &&
privateKeyPath.isEmpty == caCertificatePath.isEmpty else {
Expand All @@ -255,7 +255,7 @@ private func makeClientTLSConfiguration(
}

return .init(
certificateChain: [.file(certificatePath)],
certificateChain: try NIOSSLCertificate.fromPEMFile(certificatePath).map { .certificate($0) },
privateKey: .file(privateKeyPath),
trustRoots: .file(caCertificatePath)
)
Expand Down Expand Up @@ -363,7 +363,7 @@ Group { group in
privateKeyOption,
hostOverrideOption
) { benchmarkNames, host, port, caCertificatePath, certificatePath, privateKeyPath, hostOverride in
let tlsConfiguration = makeClientTLSConfiguration(
let tlsConfiguration = try makeClientTLSConfiguration(
caCertificatePath: caCertificatePath,
certificatePath: certificatePath,
privateKeyPath: privateKeyPath)
Expand Down Expand Up @@ -402,7 +402,7 @@ Group { group in
) { host, port, caCertificatePath, certificatePath, privateKeyPath in
let group = MultiThreadedEventLoopGroup(numberOfThreads: System.coreCount)

let tlsConfiguration = makeServerTLSConfiguration(
let tlsConfiguration = try makeServerTLSConfiguration(
caCertificatePath: caCertificatePath,
certificatePath: certificatePath,
privateKeyPath: privateKeyPath)
Expand Down
14 changes: 7 additions & 7 deletions Sources/GRPCSampleData/GRPCSwiftCertificate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,26 @@ public struct SampleCertificate {
public var notAfter: Date

public static let ca = SampleCertificate(
certificate: try! NIOSSLCertificate(buffer: Array(caCert.utf8CString), format: .pem),
certificate: try! NIOSSLCertificate(bytes: .init(caCert.utf8), format: .pem),
commonName: "foo",
// 22/07/2024 16:32:23
notAfter: Date(timeIntervalSince1970: 1721662343.0))

public static let server = SampleCertificate(
certificate: try! NIOSSLCertificate(buffer: Array(serverCert.utf8CString), format: .pem),
certificate: try! NIOSSLCertificate(bytes: .init(serverCert.utf8), format: .pem),
commonName: "localhost",
// 22/07/2024 16:32:23
notAfter: Date(timeIntervalSince1970: 1721662343.0))

public static let exampleServer = SampleCertificate(
certificate: try! NIOSSLCertificate(buffer: Array(exampleServerCert.utf8CString), format: .pem),
certificate: try! NIOSSLCertificate(bytes: .init(exampleServerCert.utf8), format: .pem),
commonName: "example.com",
// 22/07/2024 16:43:12
notAfter: Date(timeIntervalSince1970: 1721662992.0)
)

public static let client = SampleCertificate(
certificate: try! NIOSSLCertificate(buffer: Array(clientCert.utf8CString), format: .pem),
certificate: try! NIOSSLCertificate(bytes: .init(clientCert.utf8), format: .pem),
commonName: "localhost",
// 22/07/2024 16:32:23
notAfter: Date(timeIntervalSince1970: 1721662343.0))
Expand All @@ -59,9 +59,9 @@ extension SampleCertificate {
public struct SamplePrivateKey {
private init() { }

public static let server = try! NIOSSLPrivateKey(buffer: Array(serverKey.utf8CString), format: .pem)
public static let exampleServer = try! NIOSSLPrivateKey(buffer: Array(exampleServerKey.utf8CString), format: .pem)
public static let client = try! NIOSSLPrivateKey(buffer: Array(clientKey.utf8CString), format: .pem)
public static let server = try! NIOSSLPrivateKey(bytes: .init(serverKey.utf8), format: .pem)
public static let exampleServer = try! NIOSSLPrivateKey(bytes: .init(exampleServerKey.utf8), format: .pem)
public static let client = try! NIOSSLPrivateKey(bytes: .init(clientKey.utf8), format: .pem)
}

// MARK: - Certificates and private keys
Expand Down