Skip to content
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
8 changes: 4 additions & 4 deletions Sources/GRPC/GRPCChannel/GRPCChannelBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ extension ClientConnection {
///
/// gRPC Swift offers two TLS 'backends'. The 'NIOSSL' backend is available on Darwin and Linux
/// platforms and delegates to SwiftNIO SSL. On recent Darwin platforms (macOS 10.14+, iOS 12+,
/// tvOS 12+, and watchOS 5+) the 'Network.framework' backend is available. The two backends have
/// tvOS 12+, and watchOS 6+) the 'Network.framework' backend is available. The two backends have
/// a number of incompatible configuration options and users are responsible for selecting the
/// appropriate APIs. The TLS configuration options on the builder document which backends they
/// support.
Expand Down Expand Up @@ -85,7 +85,7 @@ extension ClientConnection {
///
/// - Parameter group: The `EventLoopGroup` use for the connection.
/// - Returns: A builder for a connection using the Network.framework TLS backend.
@available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *)
@available(macOS 10.14, iOS 12.0, watchOS 6.0, tvOS 12.0, *)
public static func usingTLSBackedByNetworkFramework(
on group: EventLoopGroup
) -> ClientConnection.Builder.Secure {
Expand Down Expand Up @@ -365,7 +365,7 @@ extension ClientConnection.Builder.Secure {
///
/// - Note: May only be used with the 'Network.framework' TLS backend.
@discardableResult
@available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *)
@available(macOS 10.14, iOS 12.0, watchOS 6.0, tvOS 12.0, *)
public func withTLS(localIdentity: SecIdentity) -> Self {
self.tls.updateNetworkLocalIdentity(to: localIdentity)
return self
Expand All @@ -375,7 +375,7 @@ extension ClientConnection.Builder.Secure {
///
/// - Note: May only be used with the 'Network.framework' TLS backend.
@discardableResult
@available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *)
@available(macOS 10.14, iOS 12.0, watchOS 6.0, tvOS 12.0, *)
public func withTLSHandshakeVerificationCallback(
on queue: DispatchQueue,
verificationCallback callback: @escaping sec_protocol_verify_t
Expand Down
28 changes: 14 additions & 14 deletions Sources/GRPC/GRPCTLSConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public struct GRPCTLSConfiguration {

#if canImport(Network)
case var .network(config):
if #available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *) {
if #available(macOS 10.14, iOS 12.0, watchOS 6.0, tvOS 12.0, *) {
if let hostnameOverride = newValue {
config.updateHostnameOverride(to: hostnameOverride)
} else {
Expand Down Expand Up @@ -403,7 +403,7 @@ extension GRPCTLSConfiguration {
#if canImport(Network)
extension GRPCTLSConfiguration {
internal struct NetworkConfiguration {
@available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *)
@available(macOS 10.14, iOS 12.0, watchOS 6.0, tvOS 12.0, *)
internal var options: NWProtocolTLS.Options {
get {
return self._options as! NWProtocolTLS.Options
Expand All @@ -424,13 +424,13 @@ extension GRPCTLSConfiguration {
// guards to update the value in the underlying `sec_protocol_options`.
internal private(set) var hostnameOverride: String?

@available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *)
@available(macOS 10.14, iOS 12.0, watchOS 6.0, tvOS 12.0, *)
init(options: NWProtocolTLS.Options, hostnameOverride: String?) {
self._options = options
self.hostnameOverride = hostnameOverride
}

@available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *)
@available(macOS 10.14, iOS 12.0, watchOS 6.0, tvOS 12.0, *)
internal mutating func updateHostnameOverride(to hostnameOverride: String) {
self.hostnameOverride = hostnameOverride
sec_protocol_options_set_tls_server_name(
Expand All @@ -440,7 +440,7 @@ extension GRPCTLSConfiguration {
}
}

@available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *)
@available(macOS 10.14, iOS 12.0, watchOS 6.0, tvOS 12.0, *)
public static func makeClientConfigurationBackedByNetworkFramework(
identity: SecIdentity? = nil,
hostnameOverride: String? = nil,
Expand Down Expand Up @@ -489,7 +489,7 @@ extension GRPCTLSConfiguration {
)
}

@available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *)
@available(macOS 10.14, iOS 12.0, watchOS 6.0, tvOS 12.0, *)
public static func makeClientConfigurationBackedByNetworkFramework(
options: NWProtocolTLS.Options,
hostnameOverride: String? = nil
Expand All @@ -498,7 +498,7 @@ extension GRPCTLSConfiguration {
return GRPCTLSConfiguration(backend: .network(network))
}

@available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *)
@available(macOS 10.14, iOS 12.0, watchOS 6.0, tvOS 12.0, *)
public static func makeServerConfigurationBackedByNetworkFramework(
identity: SecIdentity
) -> GRPCTLSConfiguration {
Expand All @@ -525,15 +525,15 @@ extension GRPCTLSConfiguration {
return GRPCTLSConfiguration.makeServerConfigurationBackedByNetworkFramework(options: options)
}

@available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *)
@available(macOS 10.14, iOS 12.0, watchOS 6.0, tvOS 12.0, *)
public static func makeServerConfigurationBackedByNetworkFramework(
options: NWProtocolTLS.Options
) -> GRPCTLSConfiguration {
let network = NetworkConfiguration(options: options, hostnameOverride: nil)
return GRPCTLSConfiguration(backend: .network(network))
}

@available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *)
@available(macOS 10.14, iOS 12.0, watchOS 6.0, tvOS 12.0, *)
internal mutating func updateNetworkLocalIdentity(to identity: SecIdentity) {
self.modifyingNetworkConfiguration {
sec_protocol_options_set_local_identity(
Expand All @@ -543,7 +543,7 @@ extension GRPCTLSConfiguration {
}
}

@available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *)
@available(macOS 10.14, iOS 12.0, watchOS 6.0, tvOS 12.0, *)
internal mutating func updateNetworkVerifyCallbackWithQueue(
callback: @escaping sec_protocol_verify_t,
queue: DispatchQueue
Expand Down Expand Up @@ -573,7 +573,7 @@ extension GRPCTLSConfiguration {

#if canImport(Network)
extension GRPCTLSConfiguration {
@available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *)
@available(macOS 10.14, iOS 12.0, watchOS 6.0, tvOS 12.0, *)
internal func applyNetworkTLSOptions(
to bootstrap: NIOTSConnectionBootstrap
) -> NIOTSConnectionBootstrap {
Expand All @@ -588,7 +588,7 @@ extension GRPCTLSConfiguration {
}
}

@available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *)
@available(macOS 10.14, iOS 12.0, watchOS 6.0, tvOS 12.0, *)
internal func applyNetworkTLSOptions(
to bootstrap: NIOTSListenerBootstrap
) -> NIOTSListenerBootstrap {
Expand All @@ -604,7 +604,7 @@ extension GRPCTLSConfiguration {
}
}

@available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *)
@available(macOS 10.14, iOS 12.0, watchOS 6.0, tvOS 12.0, *)
extension NIOTSConnectionBootstrap {
internal func tlsOptions(
from configuration: GRPCTLSConfiguration
Expand All @@ -613,7 +613,7 @@ extension NIOTSConnectionBootstrap {
}
}

@available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *)
@available(macOS 10.14, iOS 12.0, watchOS 6.0, tvOS 12.0, *)
extension NIOTSListenerBootstrap {
internal func tlsOptions(
from configuration: GRPCTLSConfiguration
Expand Down
2 changes: 1 addition & 1 deletion Sources/GRPC/ServerBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ extension Server {
/// Returns a `Server` builder configured with the 'Network.framework' TLS backend.
///
/// This builder must use a `NIOTSEventLoopGroup`.
@available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *)
@available(macOS 10.14, iOS 12.0, watchOS 6.0, tvOS 12.0, *)
public static func usingTLSBackedByNetworkFramework(
on group: EventLoopGroup,
with identity: SecIdentity
Expand Down
2 changes: 1 addition & 1 deletion Tests/GRPCTests/GRPCNetworkFrameworkTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import NIOTransportServices
import Security
import XCTest

@available(macOS 10.14, iOS 12.0, watchOS 5.0, tvOS 12.0, *)
@available(macOS 10.14, iOS 12.0, watchOS 6.0, tvOS 12.0, *)
final class GRPCNetworkFrameworkTests: GRPCTestCase {
private var server: Server!
private var client: ClientConnection!
Expand Down
4 changes: 2 additions & 2 deletions docs/tls.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ gRPC Swift offers two TLS 'backends'. A 'NIOSSL' backend and a 'Network.framewor

The NIOSSL backend is available on Darwin and Linux and delegates to SwiftNIO SSL. The
Network.framework backend is available on recent Darwin platforms (macOS 10.14+, iOS 12+, tvOS 12+,
and watchOS 5+) and uses the TLS implementation provided by Network.framework. Moreover, the
and watchOS 6+) and uses the TLS implementation provided by Network.framework. Moreover, the
Network.framework backend is only compatible with clients and servers using the `EventLoopGroup`
provided by SwiftNIO Transport Services, `NIOTSEventLoopGroup`.

| | NIOSSL backend | Network.framework backend |
|-----------------------------|------------------------------------------------------|---------------------------------------------|
| Platform Availability | Darwin and Linux | macOS 10.14+, iOS 12+, tvOS 12+, watchOS 5+ |
| Platform Availability | Darwin and Linux | macOS 10.14+, iOS 12+, tvOS 12+, watchOS 6+ |
| Compatible `EventLoopGroup` | `MultiThreadedEventLoopGroup`, `NIOTSEventLoopGroup` | `NIOTSEventLoopGroup` |

Note that on supported Darwin platforms users should the prefer using `NIOTSEventLoopGroup` and the
Expand Down