Documentation
¶
Index ¶
- Constants
- 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]
- 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 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(goodBits fs.FileMode) (bool, error)
- func (o File) Match(probe string) bool
- func (o File) Open() (*os.File, error)
- func (o File) OpenFile(flag int, perm os.FileMode) (*os.File, error)
- func (o File) ReadFile() (data []byte, err error)
- func (o File) Remove() 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
- func (o File) WriteFile(data []byte, perm os.FileMode) (err error)
- type FileOptionError
- 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]
- 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]
- 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
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.
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 convert path to absolute paths if possible
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 File ¶
func (File) Match ¶
Overrides Option.Match to account for relative paths potentially being different strings but representing the same file.
func (File) String ¶
Override the String() method from the inner Str just so we return the correct None[Type] string.
type FileOptionError ¶ added in v0.2.0
type FileOptionError struct {
// contains filtered or unexported fields
}
func (FileOptionError) Error ¶ added in v0.2.0
func (e FileOptionError) Error() string
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 convert path to absolute paths if possible
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 convert path to absolute paths if possible
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.