Documentation ¶
Index ¶
- Variables
- func ComputeSKI(hashType crypto.HashType, pub interface{}) ([]byte, error)
- func CreateCACertificate(cfg *CACertificateConfig) error
- func CreateCSR(cfg *CSRConfig) error
- func CreateP11Key(handle interface{}, keyType crypto.KeyType, keyId, keyPwd string) ([]byte, crypto.PrivateKey, error)
- func CreatePrivKey(keyType crypto.KeyType, keyPath, keyFile string, isTLS bool) (key crypto.PrivateKey, err error)
- func GenerateCSRTemplate(privKey crypto.PrivateKey, ...) (*x509.CertificateRequest, error)
- func GenerateCertTemplate(cfg *GenerateCertTemplateConfig) (*x509.Certificate, error)
- func InitP11Handle(handle interface{})
- func IssueCertificate(cfg *IssueCertificateConfig) error
- func ParseCertificate(certFilePath string) (*x509.Certificate, error)
- func ParseCertificateRequest(csrFilePath string) (*x509.CertificateRequest, error)
- func ParseCertificateToJson(certFilePath string) (string, error)
- func ParseP11PrivKey(handle interface{}, keySpecJson []byte) (crypto.PrivateKey, error)
- type CACertificateConfig
- type CSRConfig
- type GenerateCertTemplateConfig
- type IssueCertificateConfig
Constants ¶
This section is empty.
Variables ¶
var P11Context *pkcs11Context
P11Context pkcs11的上下文
Functions ¶
func ComputeSKI ¶
ComputeSKI 根据哈希类型和公钥,计算SKI @param hashType @param pub @return []byte @return error
func CreateCACertificate ¶
func CreateCACertificate(cfg *CACertificateConfig) error
CreateCACertificate - create ca cert file
func CreateCSR ¶
CreateCSR 根据传入的配置参数,构建一个CSR请求 @param cfg @return error
func CreateP11Key ¶ added in v2.1.0
func CreateP11Key(handle interface{}, keyType crypto.KeyType, keyId, keyPwd string) ([]byte, crypto.PrivateKey, error)
CreateP11Key - create pkcs11 private key
func CreatePrivKey ¶
func CreatePrivKey(keyType crypto.KeyType, keyPath, keyFile string, isTLS bool) (key crypto.PrivateKey, err error)
CreatePrivKey - create private key file
func GenerateCSRTemplate ¶
func GenerateCSRTemplate(privKey crypto.PrivateKey, country, locality, province, organizationalUnit, organization, commonName string) (*x509.CertificateRequest, error)
GenerateCSRTemplate 根据传入的参数生成一个x509的CertificateRequest对象 @param privKey @param country @param locality @param province @param organizationalUnit @param organization @param commonName @return *x509.CertificateRequest @return error
func GenerateCertTemplate ¶
func GenerateCertTemplate(cfg *GenerateCertTemplateConfig) (*x509.Certificate, error)
GenerateCertTemplate 根据模板配置生成一个x509证书对象 @param cfg @return *x509.Certificate @return error
func InitP11Handle ¶ added in v2.1.0
func InitP11Handle(handle interface{})
InitP11Handle 初始化PKCS11 的Handle @param handle
func IssueCertificate ¶
func IssueCertificate(cfg *IssueCertificateConfig) error
IssueCertificate - issue certification
func ParseCertificate ¶
func ParseCertificate(certFilePath string) (*x509.Certificate, error)
ParseCertificate - parse certification
func ParseCertificateRequest ¶
func ParseCertificateRequest(csrFilePath string) (*x509.CertificateRequest, error)
ParseCertificateRequest - parse certification request
func ParseCertificateToJson ¶
ParseCertificateToJson 解析证书为Json格式 @param certFilePath @return string @return error
func ParseP11PrivKey ¶ added in v2.1.0
func ParseP11PrivKey(handle interface{}, keySpecJson []byte) (crypto.PrivateKey, error)
ParseP11PrivKey 解析PKCS11出私钥对象 @param handle @param keySpecJson @return crypto.PrivateKey @return error
Types ¶
type CACertificateConfig ¶
type CACertificateConfig struct { PrivKey crypto.PrivateKey HashType crypto.HashType CertPath string CertFileName string Country string Locality string Province string OrganizationalUnit string Organization string CommonName string ExpireYear int32 Sans []string }
CACertificateConfig contains necessary parameters for creating private key.
type CSRConfig ¶
type CSRConfig struct { PrivKey crypto.PrivateKey CsrPath string CsrFileName string Country string Locality string Province string OrganizationalUnit string Organization string CommonName string }
CSRConfig contains necessary parameters for creating csr.
type GenerateCertTemplateConfig ¶
type GenerateCertTemplateConfig struct { PrivKey crypto.PrivateKey IsCA bool Country string Locality string Province string OrganizationalUnit string Organization string CommonName string ExpireYear int32 Sans []string KeyUsages []x509.KeyUsage ExtKeyUsages []x509.ExtKeyUsage }
GenerateCertTemplateConfig contains necessary parameters for creating private key.
type IssueCertificateConfig ¶
type IssueCertificateConfig struct { HashType crypto.HashType IsCA bool IssuerPrivKeyFilePath string IssuerCertFilePath string IssuerPrivKeyPwd []byte CsrFilePath string CertPath string CertFileName string ExpireYear int32 Sans []string //Uuid string KeyUsages []x509.KeyUsage ExtKeyUsages []x509.ExtKeyUsage }
IssueCertificateConfig contains necessary parameters for issuing cert.