0.6.5.b Arroyo Toad

Git commit fixes
This commit is contained in:
Christian Risi
2024-12-16 10:34:37 +01:00
940 changed files with 5098 additions and 235 deletions

View File

@@ -0,0 +1,5 @@
public enum ParsingError : Error {
case MalformedJSON(reason: String)
case ConfigFileNotExistent
case ImpossibleToWriteKeyToFileSystem
}

View File

@@ -36,6 +36,7 @@ public func fetchPrivateP256Key(deviceID: UInt) async throws -> P256.Signing.Pri
// Do nothing
}
<<<<<<< HEAD
let key = createPrivateP256Key()
@@ -57,6 +58,31 @@ public func fetchPrivateP256Key(deviceID: UInt) async throws -> P256.Signing.Pri
let _ = try await URLSession.shared.upload(for: httpRequest, from: data)
return key
=======
do {
let key = createPrivateP256Key()
let publicKey = key.publicKey.pemRepresentation
try privateP256_2_pem(privateKey: key).write(to: URL(filePath: keyFilePath), atomically: true, encoding: String.Encoding.utf8)
// UGLY: hardcoded
var httpRequest = URLRequest(url: URL(string: "http://public-key-db.internal/key")!)
httpRequest.setValue("application/json", forHTTPHeaderField: "Content-Type")
httpRequest.httpMethod = "POST"
let message = PublicKeyMessage(deviceID: deviceID, publicKey: publicKey)
let encoder = JSONEncoder()
let data = try encoder.encode(message)
httpRequest.httpBody = data
let _ = try await URLSession.shared.upload(for: httpRequest, from: data)
return key
} catch {
throw ParsingError.ImpossibleToWriteKeyToFileSystem
}
>>>>>>> 5d78c9be5855d5541dd07b24d8331c018ddd2c70

View File

@@ -0,0 +1,4 @@
public struct PublicKeyMessage : Codable {
public let deviceID: UInt
public let publicKey: String
}