Documentation ¶
Overview ¶
Package crypto provides utility functions for generating and handling certificates and key pairs.
Index ¶
- func GenerateIntermediateCA(serialNumber big.Int, issuer, subject string, notBefore, notAfter time.Time, ...) ([]byte, ed25519.PrivateKey, error)
- func GenerateRootCA(subject string) ([]byte, ed25519.PrivateKey, error)
- func ReadCertificate(r io.Reader) (*x509.Certificate, error)
- func ReadCertificateFile(path string) (*x509.Certificate, error)
- func ReadPrivateKey(r io.Reader) (ed25519.PrivateKey, error)
- func ReadPrivateKeyFile(path string) (ed25519.PrivateKey, error)
- func WriteCertificate(crt []byte, dst io.Writer) error
- func WriteCertificateFile(crt []byte, path string) error
- func WritePrivateKey(key ed25519.PrivateKey, dst io.Writer) error
- func WritePrivateKeyFile(key ed25519.PrivateKey, path string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateIntermediateCA ¶
func GenerateIntermediateCA(serialNumber big.Int, issuer, subject string, notBefore, notAfter time.Time, parentCrt x509.Certificate, parentPrivKey ed25519.PrivateKey) ([]byte, ed25519.PrivateKey, error)
GenerateIntermediateCA generates a new ed25519 keypair and returns a certificate signed by the provided parent.
If the generation of the keypair or the creation of the certificate fails an error is returned.
func GenerateRootCA ¶
func GenerateRootCA(subject string) ([]byte, ed25519.PrivateKey, error)
GenerateRootCA generates a new ed25519 keypair and returns a self signed certificate and the private key.
If the generation of the keypair or the creation of the certificate fails an error is returned.
The generated certificate has the serial number '1' and is valid for 10 years.
func ReadCertificate ¶
func ReadCertificate(r io.Reader) (*x509.Certificate, error)
ReadCertificate reads the certificate from the reader.
func ReadCertificateFile ¶
func ReadCertificateFile(path string) (*x509.Certificate, error)
ReadCertificateFile reads the certificate from the path.
func ReadPrivateKey ¶
func ReadPrivateKey(r io.Reader) (ed25519.PrivateKey, error)
ReadPrivateKey reads the private key from the reader.
func ReadPrivateKeyFile ¶
func ReadPrivateKeyFile(path string) (ed25519.PrivateKey, error)
ReadPrivateKeyFile reads the private key from the path.
func WriteCertificate ¶
WriteCertificate pem encodes the certificate and writes it to dst.
func WriteCertificateFile ¶
WriteCertificateFile pem encodes the certificate and writes it to the path.
func WritePrivateKey ¶
func WritePrivateKey(key ed25519.PrivateKey, dst io.Writer) error
WritePrivateKey pem encodes the private key and writes it to dst.
func WritePrivateKeyFile ¶
func WritePrivateKeyFile(key ed25519.PrivateKey, path string) error
WritePrivateKeyFile pem encodes the private key and writes it to the path.
Types ¶
This section is empty.