Documentation ¶
Index ¶
- Constants
- func BuildClientSimpleTLSConfig(caCert *x509.Certificate) (*tls.Config, error)
- func BuildClientTLSConfig(caCert *x509.Certificate, cert *x509.Certificate, key *rsa.PrivateKey) (*tls.Config, error)
- func BuildClientTLSConfigViaPath(caPath, certPath, keyPath string) (*tls.Config, error)
- func BuildServerTLSConfig(caCert *x509.Certificate, cert *x509.Certificate, key *rsa.PrivateKey) (*tls.Config, error)
- func BuildServerTLSConfigFromPath(caPath, certPath, keyPath string) (*tls.Config, error)
- func BuildTLSCertificate(cert *x509.Certificate, key *rsa.PrivateKey) []tls.Certificate
- func BuildTLSCertificateViaPath(certPath, keyPath string) ([]tls.Certificate, error)
- func CreateCA(subjectName string) (*rsa.PrivateKey, []byte, error)
- func CreateCAFile(subjectName, certFile, keyFile string) error
- func DecodeCert(certContent []byte) (*x509.Certificate, error)
- func DecryptOAEP(priv *rsa.PrivateKey, ciphertext string) ([]byte, error)
- func DecryptPKCS1v15(priv *rsa.PrivateKey, ciphertext string, keysize int, prefix []byte) ([]byte, error)
- func EncodeCert(cert *x509.Certificate) (string, error)
- func EncodePKCS1PrivateKey(priKey *rsa.PrivateKey) []byte
- func EncodePKCS1PublicKey(priKey *rsa.PrivateKey) []byte
- func EncodePKCS8PrivateKey(priKey *rsa.PrivateKey) ([]byte, error)
- func EncodePKCS8PublicKey(priKey *rsa.PrivateKey) ([]byte, error)
- func EncodeRsaKeyToPKCS1(key *rsa.PrivateKey) (string, error)
- func EncodeRsaKeyToPKCS8(key *rsa.PrivateKey) (string, error)
- func EncryptOAEP(pub *rsa.PublicKey, key []byte) (string, error)
- func EncryptPKCS1v15(pub *rsa.PublicKey, key []byte, prefix []byte) (string, error)
- func GenerateKeyCertPairData(rootCAKey *rsa.PrivateKey, rootCACert *x509.Certificate, commonName string) (string, string, error)
- func GenerateKeyData() (string, error)
- func GeneratePrivateKeyToFile(filename string) error
- func GenerateX509KeyPair(parent *x509.Certificate, caKey any, cert *x509.Certificate, ...) error
- func GenerateX509KeyPairStruct(parent *x509.Certificate, caKey any, certTemplate *x509.Certificate) (*rsa.PrivateKey, *x509.Certificate, error)
- func LoadCertFile(name string) ([]byte, error)
- func LoadKeyData(keyFile string) (string, error)
- func LoadX509EcKeyPair(certFile, keyFile string) (*x509.Certificate, *ecdsa.PrivateKey, error)
- func LoadX509KeyPair(certFile, keyFile string) (*x509.Certificate, *rsa.PrivateKey, error)
- func ParseCert(certData []byte, certFile string) (cert *x509.Certificate, err error)
- func ParseCertData(data []byte) (*x509.Certificate, error)
- func ParseCertFromFile(caFilePath string) (*x509.Certificate, error)
- func ParseCertWithGenerated(privateKey *rsa.PrivateKey, subject string, certData []byte, certFile string) (cert *x509.Certificate, err error)
- func ParseEncodedKey(keyDataEncoded, keyFile string) (*rsa.PrivateKey, error)
- func ParseKey(keyData []byte, keyFile string) (key *rsa.PrivateKey, err error)
- func ParseRSAPrivateKeyData(data []byte) (*rsa.PrivateKey, error)
- func ParseRSAPrivateKeyFile(serverKey string) (*rsa.PrivateKey, error)
- func ParseRSAPublicKey(der []byte) (*rsa.PublicKey, error)
- func SignWithRSA(key *rsa.PrivateKey, data string) (string, error)
- func VerifyCert(cert []byte) bool
- func VerifyEncodeCert(base64EncodeCert string) error
- func VerifySSLKey(key []byte) bool
- func WritePrivateKeyToFile(key *rsa.PrivateKey, filename string) error
- func WriteX509CertToFile(cert *x509.Certificate, filename string) error
Constants ¶
const ( RsaPKCS1PrivateKey = "RSA PRIVATE KEY" RsaPKCS8PrivateKey = "PRIVATE KEY" RsaPKCS1PublicKey = "RSA PUBLIC KEY" RsaPKCS8PublicKey = "PUBLIC KEY" CERTIFICATE = "CERTIFICATE" )
Variables ¶
This section is empty.
Functions ¶
func BuildClientSimpleTLSConfig ¶
func BuildClientSimpleTLSConfig(caCert *x509.Certificate) (*tls.Config, error)
BuildClientSimpleTLSConfig builds client tls config.
func BuildClientTLSConfig ¶
func BuildClientTLSConfig(caCert *x509.Certificate, cert *x509.Certificate, key *rsa.PrivateKey) (*tls.Config, error)
BuildClientTLSConfig builds client tls config.
func BuildClientTLSConfigViaPath ¶
BuildClientTLSConfigViaPath builds client tls config.
func BuildServerTLSConfig ¶
func BuildServerTLSConfig(caCert *x509.Certificate, cert *x509.Certificate, key *rsa.PrivateKey) (*tls.Config, error)
BuildServerTLSConfig builds server tls config.
func BuildServerTLSConfigFromPath ¶
BuildServerTLSConfigFromPath builds server tls config.
func BuildTLSCertificate ¶
func BuildTLSCertificate(cert *x509.Certificate, key *rsa.PrivateKey) []tls.Certificate
BuildTLSCertificate builds tls certificate.
func BuildTLSCertificateViaPath ¶
func BuildTLSCertificateViaPath(certPath, keyPath string) ([]tls.Certificate, error)
BuildTLSCertificateViaPath builds tls certificate.
func CreateCAFile ¶
func DecodeCert ¶
func DecodeCert(certContent []byte) (*x509.Certificate, error)
DecodeCert loads cert from string content
func DecryptOAEP ¶
func DecryptOAEP(priv *rsa.PrivateKey, ciphertext string) ([]byte, error)
func DecryptPKCS1v15 ¶
func EncodePKCS1PrivateKey ¶
func EncodePKCS1PrivateKey(priKey *rsa.PrivateKey) []byte
func EncodePKCS1PublicKey ¶
func EncodePKCS1PublicKey(priKey *rsa.PrivateKey) []byte
func EncodePKCS8PrivateKey ¶
func EncodePKCS8PrivateKey(priKey *rsa.PrivateKey) ([]byte, error)
func EncodePKCS8PublicKey ¶
func EncodePKCS8PublicKey(priKey *rsa.PrivateKey) ([]byte, error)
func EncodeRsaKeyToPKCS1 ¶
func EncodeRsaKeyToPKCS1(key *rsa.PrivateKey) (string, error)
EncodeRsaKeyToPKCS1 encode key to pkcs#1 form key.
func EncodeRsaKeyToPKCS8 ¶
func EncodeRsaKeyToPKCS8(key *rsa.PrivateKey) (string, error)
EncodeRsaKeyToPKCS8 encode key to pkcs#8 form key.
func EncryptPKCS1v15 ¶
func GenerateKeyCertPairData ¶
func GenerateKeyCertPairData(rootCAKey *rsa.PrivateKey, rootCACert *x509.Certificate, commonName string) (string, string, error)
func GenerateKeyData ¶
func GenerateX509KeyPair ¶
func GenerateX509KeyPair(parent *x509.Certificate, caKey any, cert *x509.Certificate, certOut, keyOut io.Writer) error
GenerateX509KeyPair creates a public/private key pair and creates a new X.509 v3 certificate based on a template. caKey can be ecdsa.PrivateKey or rsa.PrivateKey
func GenerateX509KeyPairStruct ¶
func GenerateX509KeyPairStruct(parent *x509.Certificate, caKey any, certTemplate *x509.Certificate) (*rsa.PrivateKey, *x509.Certificate, error)
GenerateX509KeyPairStruct creates a public/private key pair and creates a new X.509 v3 certificate based on a template. caKey can be ecdsa.PrivateKey or rsa.PrivateKey
func LoadKeyData ¶
func LoadX509EcKeyPair ¶
func LoadX509EcKeyPair(certFile, keyFile string) (*x509.Certificate, *ecdsa.PrivateKey, error)
func LoadX509KeyPair ¶
func LoadX509KeyPair(certFile, keyFile string) (*x509.Certificate, *rsa.PrivateKey, error)
LoadX509KeyPair reads and parses a public/private key pair from a pair of files. The files must contain PEM encoded data.
func ParseCert ¶
func ParseCert(certData []byte, certFile string) (cert *x509.Certificate, err error)
func ParseCertData ¶
func ParseCertData(data []byte) (*x509.Certificate, error)
func ParseCertFromFile ¶
func ParseCertFromFile(caFilePath string) (*x509.Certificate, error)
func ParseCertWithGenerated ¶
func ParseCertWithGenerated(privateKey *rsa.PrivateKey, subject string, certData []byte, certFile string) (cert *x509.Certificate, err error)
func ParseEncodedKey ¶
func ParseEncodedKey(keyDataEncoded, keyFile string) (*rsa.PrivateKey, error)
func ParseRSAPrivateKeyData ¶
func ParseRSAPrivateKeyData(data []byte) (*rsa.PrivateKey, error)
func ParseRSAPrivateKeyFile ¶
func ParseRSAPrivateKeyFile(serverKey string) (*rsa.PrivateKey, error)
func SignWithRSA ¶
func SignWithRSA(key *rsa.PrivateKey, data string) (string, error)
func VerifyCert ¶
func VerifyEncodeCert ¶
func VerifySSLKey ¶
func WritePrivateKeyToFile ¶
func WritePrivateKeyToFile(key *rsa.PrivateKey, filename string) error
func WriteX509CertToFile ¶
func WriteX509CertToFile(cert *x509.Certificate, filename string) error
Types ¶
This section is empty.