Skip to content

Instantly share code, notes, and snippets.

@alexisakers
Last active November 16, 2017 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexisakers/d8c3e3a86bdf7a02f6d3204dc8aea04a to your computer and use it in GitHub Desktop.
Save alexisakers/d8c3e3a86bdf7a02f6d3204dc8aea04a to your computer and use it in GitHub Desktop.
Get the description of a Security OSStatus
#!/usr/bin/swift
import Foundation
import Security
guard CommandLine.arguments.count > 1 else {
print("USAGE: osstatus [code]")
exit(-1)
}
guard let code = OSStatus(CommandLine.arguments[1]) else {
print("Not a valid status code.")
exit(-1)
}
guard let description = SecCopyErrorMessageString(code, nil) else {
print("Unknown error")
exit(-1)
}
print(description)
exit(0)
@alexisakers
Copy link
Author

macOS script to get the description of Security error codes.

Install

$ swiftc osstatus.swift
$ cp -f ./osstatus /usr/local/bin/osstatus

Usage

$ osstatus -25300
The specified item could not be found in the keychain.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment