Documentation ¶
Index ¶
- Constants
- type Bool
- type Cert
- func (o Cert) FilePermsValid() (bool, error)
- func (o Cert) ReadBlocks() (blocks []*pem.Block, err error)
- func (o Cert) ReadCerts() (certs []*x509.Certificate, err error)
- func (o *Cert) Replace(path string) (optional.Optional[string], error)
- func (o *Cert) Set(str string) error
- func (o Cert) SetFilePerms() error
- func (o Cert) String() string
- func (o Cert) Type() string
- func (o *Cert) UnmarshalText(text []byte) error
- func (o Cert) WriteBlocks(blocks []*pem.Block) error
- func (o Cert) WriteCerts(certs []*x509.Certificate) error
- type ConfigOptional
- type File
- func (o File) Abs() (opt File, err error)
- func (o File) Create() (*os.File, error)
- func (o File) Exists() bool
- func (o File) FilePermsValid(badBits fs.FileMode) (bool, error)
- func (o File) Match(probe string) bool
- func (o File) Open() (*os.File, error)
- func (o File) SetFilePerms(mode fs.FileMode) error
- func (o File) Stat() (stat fs.FileInfo, err error)
- func (o File) String() string
- func (o File) Type() string
- type Float32
- type Float64
- type Int
- type Int16
- type Int32
- type Int64
- type Int8
- type PrivateKey
- func (o PrivateKey) FilePermsValid() (bool, error)
- func (o PrivateKey) ReadBlocks() (blocks []*pem.Block, err error)
- func (o PrivateKey) ReadCert(in Cert) (cert tls.Certificate, err error)
- func (o PrivateKey) ReadPrivateKey() (key any, err error)
- func (o *PrivateKey) Replace(path string) (optional.Optional[string], error)
- func (o *PrivateKey) Set(str string) error
- func (o PrivateKey) SetFilePerms() error
- func (o PrivateKey) String() string
- func (o PrivateKey) Type() string
- func (o *PrivateKey) UnmarshalText(text []byte) error
- func (o PrivateKey) WriteBlocks(blocks []*pem.Block) error
- func (o PrivateKey) WritePrivateKey(key any) error
- type PubKey
- func (o PubKey) FilePermsValid() (bool, error)
- func (o PubKey) ReadBlocks() (blocks []*pem.Block, err error)
- func (o PubKey) ReadPublicKeys() (pub []any, err error)
- func (o *PubKey) Replace(path string) (optional.Optional[string], error)
- func (o *PubKey) Set(str string) error
- func (o PubKey) SetFilePerms() error
- func (o PubKey) String() string
- func (o PubKey) Type() string
- func (o *PubKey) UnmarshalText(text []byte) error
- func (o PubKey) WriteBlocks(blocks []*pem.Block) error
- func (o PubKey) WritePublicKeys(pubs []any) error
- type Str
- type Time
- func (o Time) Formats() []string
- func (o Time) MarshalJSON() ([]byte, error)
- func (o Time) MarshalText() (text []byte, err error)
- func (o *Time) Set(str string) error
- func (o Time) String() string
- func (o Time) Type() string
- func (o *Time) UnmarshalJSON(data []byte) error
- func (o *Time) UnmarshalText(text []byte) error
- func (o Time) WithFormats(formats ...string) Time
- type Uint
- type Uint16
- type Uint32
- type Uint64
- type Uint8
Constants ¶
const ( KeyFilePerms fs.FileMode = 0600 PubKeyFilePerms fs.FileMode = 0644 KeyFilePermsMask fs.FileMode = 0177 PubKeyFilePermsMask fs.FileMode = 0133 )
Verifying and setting file permissions for public/private keys and certificates use the following file mode masks. The *Perms modes are the desired permissions, while the *PermsMask consts are such that perms && mask should always be 0. The mask is only needed because _technically_ I suppose you could make a public key mode 600 or something if you really wanted.
const DEFAULT_TIME_FORMAT string = time.RFC3339
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cert ¶
type Cert struct {
// contains filtered or unexported fields
}
Cert wraps an optional path string and provides extra methods for reading, decoding, and writing pem files containing CERTIFICATE blocks.
func (Cert) FilePermsValid ¶
func (Cert) ReadBlocks ¶
func (*Cert) Replace ¶
Override the inner Replace() method to ensure we only save absolute paths to our certificates
func (Cert) SetFilePerms ¶
func (o Cert) SetFilePerms() error
func (*Cert) UnmarshalText ¶
func (Cert) WriteBlocks ¶
func (Cert) WriteCerts ¶
func (o Cert) WriteCerts(certs []*x509.Certificate) error
type ConfigOptional ¶
type ConfigOptional[T primatives] interface { optional.MutableOptional[T] // Along with String() and Set(string) error from, implements pflag.Value Type() string Set(string) error // Satisfies fmt.Stringer interface String() string // Satisfies encoding.TextUnmarshaler UnmarshalText(text []byte) error // Satisfies encoding.TextMarshaler MarshalText() (text []byte, err error) }
ConfigOptional is an extension of the Optional interface meant to make it more useful for loading confopturations.
type File ¶
type File struct {
Str
}
func (File) Match ¶
Overrides Option.Match to account for relative paths potentially being different strings but representing the same file.
type Float32 ¶
32bit sized floats
func SomeFloat32 ¶
func (Float32) MarshalText ¶
func (*Float32) UnmarshalText ¶
type Float64 ¶
64bit sized floats
func SomeFloat64 ¶
func (Float64) MarshalText ¶
func (*Float64) UnmarshalText ¶
type PrivateKey ¶
type PrivateKey struct {
// contains filtered or unexported fields
}
PubKey wraps an optional path string and provides extra methods for reading, decoding, and writing pem files containing "* PRIVATE KEY" blocks.
func NoPrivateKey ¶
func NoPrivateKey() PrivateKey
func SomePrivateKey ¶
func SomePrivateKey(path string) (PrivateKey, error)
func (PrivateKey) FilePermsValid ¶
func (PrivateKey) ReadBlocks ¶
func (PrivateKey) ReadCert ¶
func (o PrivateKey) ReadCert(in Cert) (cert tls.Certificate, err error)
ReadCert accepts a Cert struct and returns a tls.Certificate for the keypair if both Optionals are Some. This is going to be the most used case for anyone loading
func (PrivateKey) ReadPrivateKey ¶
func (o PrivateKey) ReadPrivateKey() (key any, err error)
ReadPrivateKey will return the first private key found in the given filepath or error. This may return an *rsa.PrivateKey, *ecdsa.PrivateKey, ed25519.PrivateKey (Note: that is not a pointer), or *ecdh.PrivateKey, depending on the contents of the file.
func (*PrivateKey) Replace ¶
Override the inner Replace() method to ensure we only save absolute paths to our certificates
func (*PrivateKey) Set ¶
func (o *PrivateKey) Set(str string) error
func (PrivateKey) SetFilePerms ¶
func (o PrivateKey) SetFilePerms() error
func (PrivateKey) String ¶
func (o PrivateKey) String() string
func (PrivateKey) Type ¶
func (o PrivateKey) Type() string
func (*PrivateKey) UnmarshalText ¶
func (PrivateKey) WriteBlocks ¶
func (PrivateKey) WritePrivateKey ¶
func (o PrivateKey) WritePrivateKey(key any) error
WritePrivateKey will accept any of an *rsa.PrivateKey, *dsa.PrivateKey, *ecdsa.PrivateKey, ed25519.PrivateKey (Note: a pointer), or *ecdh.PrivateKey. The key will be encoded and written to the path the PrivateKey option is set to with file permissions set appropriately.
type PubKey ¶
type PubKey struct {
// contains filtered or unexported fields
}
PubKey wraps an optional path string and provides extra methods for reading, decoding, and writing pem files containing "* PUBLIC KEY" blocks.
func SomePubKey ¶
func (PubKey) FilePermsValid ¶
func (PubKey) ReadBlocks ¶
func (PubKey) ReadPublicKeys ¶
ReadPublicKeys will return all public keys found in the given filepath or error. The keys may be of type *rsa.PublicKey, *ecdsa.PublicKey, ed25519.PublicKey (Note: that is not a pointer), or *ecdh.PublicKey, depending on the contents of the file.
func (*PubKey) Replace ¶
Override the inner Replace() method to ensure we only save absolute paths to our certificates
func (PubKey) SetFilePerms ¶
func (o PubKey) SetFilePerms() error
func (*PubKey) UnmarshalText ¶
func (PubKey) WriteBlocks ¶
func (PubKey) WritePublicKeys ¶
WritePublicKey will accept any of an *rsa.PublicKey, *dsa.PublicKey, *ecdsa.PublicKey, ed25519.PublicKey (Note: a pointer), or *ecdh.PublicKey. The key will be encoded and written to the path the PubKey option is set to with file permissions set appropriately.
type Str ¶
Str implements ConfigOptional and Optional for the string type.
func (Str) MarshalText ¶
func (*Str) UnmarshalText ¶
type Time ¶
func (Time) MarshalJSON ¶
func (Time) MarshalText ¶
func (*Time) UnmarshalText ¶
func (Time) WithFormats ¶
type Uint16 ¶
16bit sized uint
func SomeUint16 ¶
func (Uint16) MarshalText ¶
func (*Uint16) UnmarshalText ¶
type Uint32 ¶
32bit sized uint
func SomeUint32 ¶
func (Uint32) MarshalText ¶
func (*Uint32) UnmarshalText ¶
type Uint64 ¶
64bit sized uint