Documentation
¶
Index ¶
- Variables
- func CaptureOutput(f func()) (stderr string, stdout string)
- func CondDebug(msg ...string)
- func CondDebugSet(val bool)
- func CondDebugStatus() bool
- func CondDebugln(msg ...string)
- func CreateRSAKeyPair(outfileName string) error
- func CurrentFunctionName() string
- func Debug(msg ...string)
- func Debugln(msg ...string)
- func ErrorExit(errorCode uint8, msg ...string)
- func ExecCmd(cmd string, args ...string) error
- func ExitIfError(err error, exitcode uint8, msg string)
- func LoadPrivateKey(filename string) (*rsa.PrivateKey, error)
- func LogErr(msg string)
- func LogInfo(msg string)
- func LogInit(tag string)
- func LogStringInit(tag string)
- func LogWarn(msg string)
- func ParsePrivateKey(der []byte) (*rsa.PrivateKey, error)
- func Sha256bytes2bytes(bytes []byte) []byte
- func SignResponse(key *rsa.PrivateKey, digest []byte) ([]byte, error)
- func WritePrivateKey(file *os.File, privKey *rsa.PrivateKey) error
- func WritePublicKey(file *os.File, pubKey *rsa.PublicKey) error
Constants ¶
This section is empty.
Variables ¶
var OutputWriter io.Writer = os.Stderr
OutputWriter defines the default output channel. It can be changed if required.
Functions ¶
func CaptureOutput ¶
CaptureOutput get a function as its argument. It executes the function and returns the output (stderr and stdout) created by this function. While capturing this output, this output is not written to default stdout or stderr.
func CondDebug ¶
func CondDebug(msg ...string)
CondDebug outputs if debug is set without an added newline at the EOL.
func CondDebugStatus ¶
func CondDebugStatus() bool
CondDebugStatus allows to check if debug is turned on/off.
func CondDebugln ¶
func CondDebugln(msg ...string)
CondDebugln is the implementation of a global debug function. If it was turned on using CondDebugSet(true), then the string is shown to stderr. Else, no output is created.
func CreateRSAKeyPair ¶
CreateRSAKeyPair checks if the 2 required files do not exist and can be created sucessfully. Then, it transfers control to createKeyPairError2.
func CurrentFunctionName ¶
func CurrentFunctionName() string
CurrentFunctionName returns the name of the current function being executed.
func Debugln ¶
func Debugln(msg ...string)
Debugln outputs a message with adding a newline at the EOL
func ErrorExit ¶
ErrorExit exits the application with the specified error code. The output is written to the assigned output writer, by default stderr.
func ExecCmd ¶
ExecCmd is a helper to execute an external application. If the exit status of this command is non-zero, then an error is returned, else nil.
func ExitIfError ¶
ExitIfError exists using ErrorExit if the supplied err is not nil. In such a case, the error message of err will be added to the message.
func LoadPrivateKey ¶
func LoadPrivateKey(filename string) (*rsa.PrivateKey, error)
LoadPrivateKey load a PEM-encoded RSA private key from a file
func LogErr ¶
func LogErr(msg string)
LogErr creates a message preprended with ERROR to syslog and stderr, but tries to continue execution.
func LogStringInit ¶
func LogStringInit(tag string)
LogStringInit does not use syslog (for dockerised environments. Instead, it writes all messages to stderr) This is suited for dockerised environments.
func LogWarn ¶
func LogWarn(msg string)
LogWarn creates a syslog and STDERR message labeled with WARNING.
func ParsePrivateKey ¶
func ParsePrivateKey(der []byte) (*rsa.PrivateKey, error)
ParsePrivateKey load a PEM-encoded RSA private key from a buffer
func Sha256bytes2bytes ¶
Sha256bytes2bytes converts a byte sequence into a SHA-256-based digest of it. The output for this application is the same on the commadn line with: curl -q localhost:8888 | jq -c .Data | tr -d '\n' | shasum -a256 The added newline must be removed. Alternatively, gnu-sed can be used instad of tr: gsed -Ez 's/\n$//' The complete JSON return structure only consists of US-ASCII characters. So potential different escaping for special characters do not have to be considered.
func SignResponse ¶
func SignResponse(key *rsa.PrivateKey, digest []byte) ([]byte, error)
SignResponse returns a signature for the given digest or returns an error
func WritePrivateKey ¶
func WritePrivateKey(file *os.File, privKey *rsa.PrivateKey) error
WritePrivateKey converts the key to PEM format and writes them to a file.
Types ¶
This section is empty.