Documentation
¶
Overview ¶
Package files provides utilities for handling and validating files like PEM, JWT, etc.
Index ¶
- func DecodePem(pemData []byte, filePath string, returnParsed bool) (any, error)
- func DeleteFile(path string, file string) error
- func EncodePem(publicKeyRaw ed25519.PublicKey, privateKeyRaw ed25519.PrivateKey, ...) (publicKey []byte, privateKey []byte, certificate []byte, err error)
- func LoadJWT(logger *slog.Logger, path string, file string, required bool) ([]byte, error)
- func LoadPEM(logger *slog.Logger, path string, file string, required bool) (any, error)
- func LoadString(logger *slog.Logger, path string, file string, required bool) (string, error)
- func WritePEM(path string, file string, data string, mode os.FileMode) error
- func WriteString(path string, file string, data string, mode os.FileMode) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodePem ¶
DecodePem decodes and parses PEM data, returning the parsed cryptographic object For validation only (when returnParsed is false), returns nil on success For loading (when returnParsed is true), returns the parsed key/certificate
func DeleteFile ¶
func EncodePem ¶
func EncodePem(publicKeyRaw ed25519.PublicKey, privateKeyRaw ed25519.PrivateKey, certificateRaw *x509.Certificate) (publicKey []byte, privateKey []byte, certificate []byte, err error)
EncodePem encodes an ed25519 public key, ed25519 private key, and/or x509 certificate into PEM format. Note that return values are nil if corresponding input is nil.
func LoadJWT ¶
LoadJWT reads a JWT token from a file (first line only, trimmed). Returns nil if the file does not exist and required is false.
func LoadPEM ¶
LoadPEM reads and parses a PEM file, returning the parsed cryptographic object. Returns nil if the file does not exist and required is false. Supported types: ed25519.PublicKey, ed25519.PrivateKey, *x509.Certificate
func LoadString ¶
LoadString reads a text file and returns its contents as a trimmed string. Returns empty string if the file does not exist and required is false.
Types ¶
This section is empty.