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
10 changes: 3 additions & 7 deletions Sources/RootsEncoder/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,9 @@ if CommandLine.arguments.contains("test") {
s += "import Foundation\n"
s += "\n"

s += "public func roots_pem() -> String {\n"
s += "public let kRootCertificates: String = \"\"\"\n"
let fileURL = URL(fileURLWithPath: "Assets/roots.pem")
let filedata = try Data(contentsOf: fileURL)
let encoding = filedata.base64EncodedString()
s += " let roots = \n"
s += " \"" + encoding + "\"\n"
s += " return String(data: Data(base64Encoded: roots, options: [])!, encoding: .utf8)!\n"
s += "}\n"
s += try String(contentsOf: fileURL)
s += "\"\"\""
}
print(s)
4 changes: 2 additions & 2 deletions Sources/SwiftGRPC/Core/Channel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class Channel {
underlyingChannel = withExtendedLifetime(argumentWrappers) {
var argumentValues = argumentWrappers.map { $0.wrapped }
if secure {
return cgrpc_channel_create_secure(address, roots_pem(), nil, nil, &argumentValues, Int32(arguments.count))
return cgrpc_channel_create_secure(address, kRootCertificates, nil, nil, &argumentValues, Int32(arguments.count))
} else {
return cgrpc_channel_create(address, &argumentValues, Int32(arguments.count))
}
Expand Down Expand Up @@ -83,7 +83,7 @@ public class Channel {
/// - Parameter clientCertificates: a PEM representation of the client certificates to use
/// - Parameter clientKey: a PEM representation of the client key to use
/// - Parameter arguments: list of channel configuration options
public init(address: String, certificates: String = roots_pem(), clientCertificates: String? = nil, clientKey: String? = nil, arguments: [Argument] = []) {
public init(address: String, certificates: String = kRootCertificates, clientCertificates: String? = nil, clientKey: String? = nil, arguments: [Argument] = []) {
gRPC.initialize()
host = address
let argumentWrappers = arguments.map { $0.toCArg() }
Expand Down
4,448 changes: 4,443 additions & 5 deletions Sources/SwiftGRPC/Core/Roots.swift

Large diffs are not rendered by default.