Documentation ¶
Index ¶
- Variables
- func CommandWithSudo(cmd ...string) *exec.Cmd
- func Install(cert *x509.Certificate, opts ...Option) error
- func InstallFile(filename string, opts ...Option) error
- func ReadCertificate(filename string) (*x509.Certificate, error)
- func SaveCertificate(filename string, cert *x509.Certificate) error
- func Uninstall(cert *x509.Certificate, opts ...Option) error
- func UninstallFile(filename string, opts ...Option) error
- type CmdError
- type JavaTrust
- type NSSTrust
- type Option
- type Trust
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotSupported is the error to indicate that the install of the // certificate is not supported on the system. ErrNotSupported = errors.New("install is not supported on this system") // ErrNotFound is the error to indicate that a cert was not found. ErrNotFound = errors.New("no certs found") // ErrInvalidCertificate is the error to indicate that a cert contains bad data. ErrInvalidCertificate = errors.New("invalid PEM data") // ErrTrustExists is the error returned when a trust already exists. ErrTrustExists = errors.New("trust already exists") // ErrTrustNotFound is the error returned when a trust does not exists. ErrTrustNotFound = errors.New("trust does not exists") // ErrTrustNotSupported is the error returned when a trust is not supported. ErrTrustNotSupported = errors.New("trust not supported") )
var ( // NSSProfile is the path of the Firefox profiles. NSSProfile = os.Getenv("HOME") + "/.mozilla/firefox/*" // CertutilInstallHelp is the command to run on linux to add NSS support. CertutilInstallHelp = `apt install libnss3-tools" or "yum install nss-tools` // SystemTrustFilename is the format used to name the root certificates. SystemTrustFilename string // SystemTrustCommand is the command used to update the system truststore. SystemTrustCommand []string )
var JavaStorePass = "changeit"
JavaStorePass is the default store password of the keystore.
Functions ¶
func CommandWithSudo ¶
func Install ¶
func Install(cert *x509.Certificate, opts ...Option) error
Install installs the given certificate into the system truststore, and optionally to the Firefox and Java trustores.
func InstallFile ¶
InstallFile will read the certificate in the given file and install it to the system truststore, and optionally to the Firefox and Java truststores.
func ReadCertificate ¶
func ReadCertificate(filename string) (*x509.Certificate, error)
ReadCertificate reads a certificate file and returns a x509.Certificate struct.
func SaveCertificate ¶
func SaveCertificate(filename string, cert *x509.Certificate) error
SaveCertificate saves the given x509.Certificate with the given filename.
func Uninstall ¶
func Uninstall(cert *x509.Certificate, opts ...Option) error
Uninstall removes the given certificate from the system truststore, and optionally from the Firefox and Java truststres.
func UninstallFile ¶
UninstallFile reads the certificate in the given file and removes it from the system truststore, and optionally to the Firefox and Java truststores.
Types ¶
type CmdError ¶
type CmdError struct {
// contains filtered or unexported fields
}
CmdError is the error used when an executable fails.
func NewCmdError ¶
NewCmdError creates a new CmdError.
type JavaTrust ¶
type JavaTrust struct {
// contains filtered or unexported fields
}
JavaTrust implements a Trust for the Java runtime.
func NewJavaTrust ¶
NewJavaTrust initializes a new JavaTrust if the environment has java installed.
func (*JavaTrust) Exists ¶
func (t *JavaTrust) Exists(cert *x509.Certificate) bool
Exists implements the Trust interface.
func (*JavaTrust) Install ¶
func (t *JavaTrust) Install(filename string, cert *x509.Certificate) error
Install implements the Trust interface.
type NSSTrust ¶
type NSSTrust struct {
// contains filtered or unexported fields
}
NSSTrust implements a Trust for Firefox or other NSS based applications.
func (*NSSTrust) Exists ¶
func (t *NSSTrust) Exists(cert *x509.Certificate) bool
Exists implements the Trust interface. Exists checks if the certificate is already installed.
func (*NSSTrust) Install ¶
func (t *NSSTrust) Install(filename string, cert *x509.Certificate) error
Install implements the Trust interface.
type Option ¶
type Option func(*options)
Option is the type used to pass custom options.
func WithFirefox ¶
func WithFirefox() Option
WithFirefox enables the install or uninstall of a certificate in the Firefox truststore.
func WithJava ¶
func WithJava() Option
WithJava enables the install or uninstall of a certificate in the Java truststore.
func WithNoSystem ¶
func WithNoSystem() Option
WithNoSystem disables the install or uninstall of a certificate in the system truststore.
func WithPrefix ¶
WithPrefix sets a custom prefix for the truststore name.
type Trust ¶
type Trust interface { Name() string Install(filename string, cert *x509.Certificate) error Uninstall(filename string, cert *x509.Certificate) error Exists(cert *x509.Certificate) bool PreCheck() error }
Trust is the interface that non-system trustores implement to add and remove a certificate on its trustore. Right now we there are two implementations of trust NSS (Firefox) and Java.