Versions in this module Expand all Collapse all v1 v1.3.1 Jul 11, 2023 Changes in this version + const DEFAULT_CERT_VALID_TIME + const DEFAULT_CSR_COUNTRIY + const DEFAULT_CSR_LOCALITY + const DEFAULT_CSR_PROVINCE + const NO_PKCS11_KEY_ID + const SM2 + const SM3 + const TokenExpireSeconds + func CheckCert(orgId string, userId string, userType db.UserType, certUsage db.CertUsage) error + func CheckParameters(orgId, userId, userTypeStr, certUsageStr string) (userType db.UserType, certUsage db.CertUsage, err error) + func CheckParametersEmpty(parameters ...string) error + func CheckParametersUserType(userTypeStr string) (db.UserType, error) + func ConvertToCertContent(certBytes []byte) (cert *x509.Certificate, certContent *db.CertContent, err error) + func ConvertToKeyPair(privateKeyBytes []byte) (keyPair *db.KeyPair, privateKey crypto.PrivateKey, err error) + func CreateCertInfo(certContent *db.CertContent, privateKeyId string, conditions *CertConditions) (*db.CertInfo, error) + func CreateDir(dirPath string) error + func CreateIntermediateCA() error + func CreateKeyPair(privateKeyTypeStr, hashTypeStr, privateKeyPwd, keyId string) (privateKey crypto.PrivateKey, keyPair *db.KeyPair, err error) + func CreateKeyPairNoEnc(privateKeyTypeStr, hashTypeStr, keyId string) (privateKey crypto.PrivateKey, keyPair *db.KeyPair, err error) + func CreateRootCa() error + func ExtKeyUsageToString(extKeyUsage []x509.ExtKeyUsage) (string, error) + func GenCrl(genCrlReq *GenCrlReq) ([]byte, error) + func GenCsr(genCsrReq *GenCsrReq) ([]byte, error) + func GenDoubleIntermediateCA(caConfig *utils.ImCaConfig) error + func GenSingleIntermediateCA(caConfig *utils.ImCaConfig, caType utils.CaType) error + func GenToken(appId string, appRole db.AccessRole) (string, error) + func GenerateDoubleRootCa(rootCsrConf *utils.CsrConf) error + func GenerateRootCa(rootCaConf *utils.CaConfig) error + func GenerateSingleRootCa(rootCsrConf *utils.CsrConf, rootCertConf *utils.CertConf, ...) error + func GetAppToken(appId, appKey string) (string, error) + func GetP2pNetNodeId(userType db.UserType, certUsage db.CertUsage, nodeTlsCrtBytes []byte) (string, error) + func GetRootPrivateKey(certUsage db.CertUsage) (crypto.PrivateKey, error) + func GetTLSCertNodeId(getNodeIdReq *GetTLSCertNodeIdReq) (nodeId string, err error) + func GetX509Certificate(sn int64) (*x509.Certificate, error) + func InitAccessControl() (bool, error) + func InitServer() + func IsAccessControlFromConfig() bool + func IssueCertBySelf(rootCertConf *RootCertRequestConfig) (*db.CertContent, error) + func IssueCertificate(certConf *CertRequestConfig) (*db.CertContent, error) + func KeyBytesToPrivateKey(privateKeyBytes []byte, keyPwd string) (privateKey crypto.PrivateKey, err error) + func LoadDoubleRootCa() error + func LoadRootCaFromConfig() error + func LoadSingleRootCa(certConf *utils.CertConf, certUsage db.CertUsage) error + func ParseCertificate(certBytes []byte) (*x509.Certificate, error) + func ParseCsr(csrBytes []byte) (*x509.CertificateRequest, error) + func ParsePrivateKey(privateKeyBytes []byte) (crypto.PrivateKey, error) + func RevokeCert(revokeCertReq *RevokeCertReq) ([]byte, error) + func ServerPortFromConfig() string + func UpdateCert(updateConf *UpdateCertConfig) (*db.CertContent, error) + func WirteFile(filePath string, fileBytes []byte) error + type AppInfo struct + AppId string + AppKey string + AppRole db.AccessRole + type ApplyCertResp struct + CertContent string + CertSn int64 + IssueCertSn int64 + PrivateKey string + func GenCert(genCertReq *GenCertReq) (*ApplyCertResp, error) + func GenCertByCsr(genCertByCsrReq *GenCertByCsrReq) (*ApplyCertResp, error) + func RenewCert(renewCertReq *RenewCertReq) (*ApplyCertResp, error) + type CSRRequest struct + Country string + Locality string + OrgId string + PrivateKey crypto.PrivateKey + Province string + UserId string + UserType db.UserType + type CSRRequestConfig struct + CommonName string + Country string + Locality string + Organization string + OrganizationalUnit string + PrivateKey crypto.PrivateKey + Province string + func BuildCSRReqConf(csrReq *CSRRequest) *CSRRequestConfig + type CertConditions struct + CertUsage db.CertUsage + OrgId string + UserId string + UserType db.UserType + type CertInfos struct + CertContent string + CertSn int64 + CertUsage string + ExpirationDate int64 + IsRevoked bool + IssuerSn int64 + OrgId string + UserId string + UserType string + func QueryCerts(req *QueryCertsReq) ([]*CertInfos, error) + type CertRequestConfig struct + CertUsage db.CertUsage + CsrBytes []byte + HashType crypto.HashType + IssuerCertBytes []byte + IssuerPrivateKey crypto.PrivateKey + UserType db.UserType + ValidTime time.Duration + type Claims struct + AppId string + AppRole db.AccessRole + func ParseToken(tokenString string) (*Claims, error) + func (c Claims) Valid() error + type GenCertByCsrReq struct + CertUsage db.CertUsage + CsrBytes []byte + OrgId string + UserId string + UserType db.UserType + type GenCertReq struct + CertUsage db.CertUsage + Country string + Locality string + OrgId string + PrivateKeyPwd string + Province string + UserId string + UserType db.UserType + type GenCertRequestConfig struct + CertUsage db.CertUsage + CommonName string + Country []string + Extension []pkix.Extension + ExtraExtensions []pkix.Extension + Locality []string + Organization []string + OrganizationalUnit []string + Province []string + UserType db.UserType + ValidTime time.Duration + type GenCrlReq struct + IssuerCertSn int64 + type GenCsrReq struct + Country string + Locality string + OrgId string + PrivateKeyPwd string + Province string + UserId string + UserType db.UserType + type GetTLSCertNodeIdReq struct + CertSn int64 + CertUsage db.CertUsage + OrgId string + UserId string + UserType db.UserType + type OptionFunc func(*Pkcs11Config) + func WithPrivKeyId(keyId string) OptionFunc + func WithPrivKeyType(keyType crypto.KeyType) OptionFunc + type Pkcs11Config struct + func NewPkcs11Config(opts ...OptionFunc) (p11Conf *Pkcs11Config) + type QueryCertsReq struct + CertSn int64 + CertUsage string + OrgId string + UserId string + UserType string + type RenewCertReq struct + CertSn int64 + type RevokeCertReq struct + IssuerCertSn int64 + Reason string + RevokedCertSn int64 + type RootCertRequestConfig struct + CertUsage db.CertUsage + CommonName string + Country string + HashType string + Locality string + Organization string + OrganizationalUnit string + PrivateKey crypto.PrivateKey + Province string + UserType db.UserType + ValidTime time.Duration + type UpdateCertConfig struct + IssuerCertBytes []byte + IssuerKey crypto.PrivateKey + OldCert *x509.Certificate + OldCsrBytes []byte