Commit 8136677a authored by Drew's avatar Drew

Support FISA_IDENTITY environment variable

parent e38823e0
Pipeline #2847 failed with stages
in 2 minutes and 30 seconds
......@@ -160,7 +160,15 @@ extension FISA.File {
*/
public init(existing: Bool, fisaPath : String = FISA.DefaultFISAPath, identityPath: String = FISA.DefaultIdentityPath) throws {
precondition(existing, "Use the other constructor if you want to create a brand-new FISA file.")
let key = try CryptoBoxSecretKey(readFromFile: identityPath)
let key: CryptoBoxSecretKey
if identityPath == FISA.DefaultIdentityPath, let env = getenv("FISA_IDENTITY") {
let identity = String(cString: env)
var bytes = Array<UInt8>.byteArrayWithBase64(identity)
key = try CryptoBoxSecretKey(bytes: &bytes)
}
else {
key = try CryptoBoxSecretKey(readFromFile: identityPath)
}
try self.init(contentsOfFile: fisaPath, identity: key)
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment