diff --git a/Sources/VaporAPNS/VaporAPNS.swift b/Sources/VaporAPNS/VaporAPNS.swift index 1b22962..19307be 100644 --- a/Sources/VaporAPNS/VaporAPNS.swift +++ b/Sources/VaporAPNS/VaporAPNS.swift @@ -59,13 +59,13 @@ open class VaporAPNS { let headers = self.requestHeaders(for: message) var curlHeaders: UnsafeMutablePointer? if !options.usesCertificateAuthentication { - let decodedKey = options.privateKey! + let privateKey = options.privateKey! let jwt = try! JWT(additionalHeaders: [KeyID(options.keyId!)], payload: Node([IssuerClaim(options.teamId!), IssuedAtClaim()]), encoding: Base64URLEncoding(), - signer: ES256(key: decodedKey)) + signer: ES256(encodedKey: privateKey)) let tokenString = try! jwt.createToken() @@ -73,7 +73,7 @@ open class VaporAPNS { do { let jwt2 = try JWT(token: tokenString, encoding: Base64URLEncoding()) - let verified = try jwt2.verifySignatureWith(ES256(key: publicKey)) + let verified = try jwt2.verifySignatureWith(ES256(encodedKey: publicKey)) if !verified { return Result.error(apnsId: message.messageId, deviceToken: deviceToken, error: .invalidSignature) } diff --git a/Tests/VaporAPNSTests/VaporAPNSTests.swift b/Tests/VaporAPNSTests/VaporAPNSTests.swift index f778673..87569b5 100644 --- a/Tests/VaporAPNSTests/VaporAPNSTests.swift +++ b/Tests/VaporAPNSTests/VaporAPNSTests.swift @@ -51,13 +51,13 @@ class VaporAPNSTests: XCTestCase { // TODO: Set this up so others can test this let jwt = try! JWT( additionalHeaders: [KeyID("E811E6AE22")], payload: Node([IssuerClaim("D86BEC0E8B"), IssuedAtClaim()]), - signer: ES256(key: "ALEILVyGWnbBaSaIFDsh0yoZaK+Ej0po/55jG2FR6u6C")) + signer: ES256(encodedKey: "ALEILVyGWnbBaSaIFDsh0yoZaK+Ej0po/55jG2FR6u6C")) let tokenString = try! jwt.createToken() do { let jwt2 = try JWT(token: tokenString) - let verified = try jwt2.verifySignatureWith(ES256(key: "BKqKwB6hpXp9SzWGt3YxnHgCEkcbS+JSrhoqkeqru/Nf62MeE958RIiKYsLFA/czdE7ThCt46azneU0IBnMCuQU=")) + let verified = try jwt2.verifySignatureWith(ES256(encodedKey: "BKqKwB6hpXp9SzWGt3YxnHgCEkcbS+JSrhoqkeqru/Nf62MeE958RIiKYsLFA/czdE7ThCt46azneU0IBnMCuQU=")) XCTAssertTrue(verified) } catch { print(error)