Skip to content

Commit

Permalink
Merge pull request #15 from dimitribouniol/dimitri/fixes
Browse files Browse the repository at this point in the history
Account JWK Fixes
  • Loading branch information
m-barthelemy authored Nov 25, 2024
2 parents b93d4df + 15e88fc commit 4151363
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
8 changes: 4 additions & 4 deletions Sources/AcmeSwift/APIs/AcmeSwift+Orders.swift
Original file line number Diff line number Diff line change
Expand Up @@ -334,9 +334,9 @@ extension AcmeSwift {
let jwk = JWK.ecdsa(
nil,
identifier: nil,
x: publicKey.prefix(upTo: publicKey.count/2).base64EncodedString(),
y: publicKey.suffix(from: publicKey.count/2).base64EncodedString(),
curve: nil
x: publicKey.prefix(publicKey.count/2).toBase64UrlString(),
y: publicKey.suffix(publicKey.count/2).toBase64UrlString(),
curve: .p256
)
let encoder = JSONEncoder()
encoder.outputFormatting = .sortedKeys
Expand All @@ -347,6 +347,6 @@ extension AcmeSwift {

extension SHA256Digest {
var base64URLString: String {
Data(self).base64EncodedString().base64ToBase64Url()
Data(self).toBase64UrlString()
}
}
8 changes: 4 additions & 4 deletions Sources/AcmeSwift/Helpers/AcmeRequestBody.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ struct AcmeRequestBody<T: EndpointProtocol>: Encodable {

self.protected = .init(
alg: .es256,
jwk: accountURL == nil ? JWTKit.JWK.ecdsa(
jwk: accountURL == nil ? JWK.ecdsa(
nil,
identifier: nil,
x: publicKey.prefix(upTo: publicKey.count/2).base64EncodedString(),
y: publicKey.suffix(from: publicKey.count/2).base64EncodedString(),
curve: nil
x: publicKey.prefix(publicKey.count/2).toBase64UrlString(),
y: publicKey.suffix(publicKey.count/2).toBase64UrlString(),
curve: .p256
) : nil,
kid: accountURL,
nonce: nonce,
Expand Down
2 changes: 0 additions & 2 deletions Sources/AcmeSwift/Models/AcmeError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ public enum AcmeError: Error, Sendable {
/// No nonce (anti-replay) value was returned by the endpoint
case noNonceReturned

case jwsEncodeError(String)

case dataCorrupted(String)
case errorCode(UInt, String)

Expand Down
2 changes: 1 addition & 1 deletion Tests/AcmeSwiftTests/AccountTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ final class AccountTests: XCTestCase {
self.logger = Logger.init(label: "acme-swift-tests")
self.logger.logLevel = .trace

var config = HTTPClient.Configuration(certificateVerification: .fullVerification, backgroundActivityLogger: self.logger)
let config = HTTPClient.Configuration(certificateVerification: .fullVerification, backgroundActivityLogger: self.logger)
self.http = HTTPClient(
eventLoopGroupProvider: .singleton,
configuration: config
Expand Down

0 comments on commit 4151363

Please sign in to comment.