Documentation ¶
Overview ¶
Package security is responsible for generating keys and certificate requests
Index ¶
- func DecryptAES(key string, data []byte) ([]byte, error)
- func EncryptStringAES(key string, data []byte) ([]byte, error)
- func GenerateCertificateRequest(country, organization, unit, mail string, key *rsa.PrivateKey) (string, error)
- func GenerateKeys(bits int, passphrase string) (*rsa.PrivateKey, error)
- func GetCertificate(filename string) (*x509.Certificate, error)
- func GetPrivateKey(filename, passphrase string) (*rsa.PrivateKey, error)
- func SaveCertificate(cert, filename string) error
- type AuthContainer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecryptAES ¶
DecryptAES deciphers the data using AES-256 algorithm
func EncryptStringAES ¶
EncryptStringAES enciphers the data using AES-256 algorithm
func GenerateCertificateRequest ¶
func GenerateCertificateRequest(country, organization, unit, mail string, key *rsa.PrivateKey) (string, error)
GenerateCertificateRequest generate a certificate request from data, and return a PEM-encoded certificate as a string
func GenerateKeys ¶
func GenerateKeys(bits int, passphrase string) (*rsa.PrivateKey, error)
GenerateKeys generate a pair of keys and save it to the disk
func GetCertificate ¶
func GetCertificate(filename string) (*x509.Certificate, error)
GetCertificate return the Certificate stored on the disk
func GetPrivateKey ¶
func GetPrivateKey(filename, passphrase string) (*rsa.PrivateKey, error)
GetPrivateKey return the private key stored on the disk
func SaveCertificate ¶
SaveCertificate saves a PEM-encoded certificate on disk
Types ¶
type AuthContainer ¶
type AuthContainer struct { Passphrase string CA *x509.Certificate Cert *x509.Certificate Key *rsa.PrivateKey }
AuthContainer contains common information for TLS authentication. Files are not loaded from the beginning, call LoadFiles to load them.
func NewAuthContainer ¶
func NewAuthContainer(passphrase string) *AuthContainer
NewAuthContainer is a shortcut to build an AuthContainer
func (*AuthContainer) LoadFiles ¶
func (a *AuthContainer) LoadFiles() (ca *x509.Certificate, cert *x509.Certificate, key *rsa.PrivateKey, err error)
LoadFiles tries to load the required certificates and key for TLS authentication