Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesnocentini committed May 21, 2019
1 parent 7db19b9 commit d18ef0c
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions modules/ROOT/examples/swift/code-snippets/SampleCodeTest.swift
Expand Up @@ -729,12 +729,14 @@ class SampleCodeTest {
#endif

func dontTestCertificatePinning() throws {
let url = URL(string: "wss://localhost:4985/db")!
let target = URLEndpoint(url: url)

// tag::certificate-pinning[]
let data = try self.dataFromResource(name: "cert", ofType: "cer")
let certificate = SecCertificateCreateWithData(nil, data)
let certURL = Bundle.main.url(forResource: "cert", withExtension: "cer")!
let data = try! Data(contentsOf: certURL)
let certificate = SecCertificateCreateWithData(nil, data as CFData)

let url = URL(string: "wss://localhost:4985/db")!
let target = URLEndpoint(url: url)

let config = ReplicatorConfiguration(database: database, target: target)
config.pinnedServerCertificate = certificate
Expand Down

0 comments on commit d18ef0c

Please sign in to comment.