Documentation ¶
Index ¶
- func CreateCertificateAuthority(key *Key, expires time.Time, organization string, country string) (*Certificate, *CertificateAuthorityInfo, error)
- func GenerateSubjectKeyId(pub crypto.PublicKey) ([]byte, error)
- func ParseAndValidateIPs(ip_list string) (res []net.IP, e error)
- type Certificate
- func CreateCertificateHost(crtAuth *Certificate, info *CertificateAuthorityInfo, keyAuth *Key, ...) (*Certificate, error)
- func CreateUserCertificate(key *Key, username string, expires time.Time) (*Certificate, error)
- func NewCertificateFromDER(derBytes []byte) *Certificate
- func NewCertificateFromPEM(data []byte) (c *Certificate, err error)
- func (c *Certificate) CheckAuthority() error
- func (c *Certificate) EncodeBase64() (*string, error)
- func (c *Certificate) Export() ([]byte, error)
- func (c *Certificate) Fingerprint() ([]byte, error)
- func (c *Certificate) GetExpirationDuration() time.Duration
- func (c *Certificate) GetRawCertificate() (*x509.Certificate, error)
- func (c *Certificate) Save(out *string) error
- func (c *Certificate) VerifyFingerprint(expectedFingerprint *[]byte) error
- func (c *Certificate) VerifyHost(hostCert *Certificate, name string) error
- type CertificateAuthorityInfo
- type CertificateSigningRequest
- func CreateCertificateSigningRequest(key *Key, name string, ip_list string, domain_list string, organization string, ...) (*CertificateSigningRequest, error)
- func NewCertificateSigningRequestFromDER(derBytes []byte) *CertificateSigningRequest
- func NewCertificateSigningRequestFromPEM(data []byte) (*CertificateSigningRequest, error)
- func (c *CertificateSigningRequest) CheckSignature() error
- func (c *CertificateSigningRequest) Export() ([]byte, error)
- func (c *CertificateSigningRequest) GetCommonNameCertificateSigningRequest() (string, error)
- func (c *CertificateSigningRequest) GetRawCertificateSigningRequest() (*x509.CertificateRequest, error)
- type Key
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateCertificateAuthority ¶
func CreateCertificateAuthority(key *Key, expires time.Time, organization string, country string) (*Certificate, *CertificateAuthorityInfo, error)
CreateCertificateAuthority creates Certificate Authority using existing key. CertificateAuthorityInfo returned is the extra infomation required by Certificate Authority.
func GenerateSubjectKeyId ¶
GenerateSubjectKeyId generates SubjectKeyId used in Certificate Id is 160-bit SHA-1 hash of the value of the BIT STRING subjectPublicKey
Types ¶
type Certificate ¶
type Certificate struct {
// contains filtered or unexported fields
}
func CreateCertificateHost ¶
func CreateCertificateHost(crtAuth *Certificate, info *CertificateAuthorityInfo, keyAuth *Key, csr *CertificateSigningRequest, days int) (*Certificate, error)
CreateCertificateHost creates certificate for host. The arguments include CA certificate, CA certificate info, CA key, certificate request.
func CreateUserCertificate ¶
CreateUserCertificate create a simple self-signed cert
func NewCertificateFromDER ¶
func NewCertificateFromDER(derBytes []byte) *Certificate
NewCertificateFromDER inits Certificate from DER-format bytes
func NewCertificateFromPEM ¶
func NewCertificateFromPEM(data []byte) (c *Certificate, err error)
NewCertificateFromPEM inits Certificate from PEM-format bytes data should contain at most one certificate
func (*Certificate) CheckAuthority ¶
func (c *Certificate) CheckAuthority() error
CheckAuthority checks the authority of certificate against itself. It only ensures that certificate is self-explanatory, and cannot promise the validity and security.
func (*Certificate) EncodeBase64 ¶
func (c *Certificate) EncodeBase64() (*string, error)
func (*Certificate) Export ¶
func (c *Certificate) Export() ([]byte, error)
Export returns PEM-format bytes
func (*Certificate) Fingerprint ¶
func (c *Certificate) Fingerprint() ([]byte, error)
func (*Certificate) GetExpirationDuration ¶
func (c *Certificate) GetExpirationDuration() time.Duration
GetExpirationDuration gets time duration before expiration
func (*Certificate) GetRawCertificate ¶
func (c *Certificate) GetRawCertificate() (*x509.Certificate, error)
GetRawCertificate returns a copy of this certificate as an x509.Certificate
func (*Certificate) Save ¶
func (c *Certificate) Save(out *string) error
func (*Certificate) VerifyFingerprint ¶
func (c *Certificate) VerifyFingerprint(expectedFingerprint *[]byte) error
func (*Certificate) VerifyHost ¶
func (c *Certificate) VerifyHost(hostCert *Certificate, name string) error
VerifyHost verifies the host certificate using host name. Only certificate of authority could call this function successfully. Current implementation allows one CA and direct hosts only, so the organization is always this:
CA host1 host2 host3
type CertificateAuthorityInfo ¶
type CertificateAuthorityInfo struct { // SerialNumber that has been used so far // Recorded to ensure all serial numbers issued by the CA are different SerialNumber *big.Int }
CertificateAuthorityInfo includes extra information required for CA
func NewCertificateAuthorityInfo ¶
func NewCertificateAuthorityInfo(serialNumber int64) *CertificateAuthorityInfo
func NewCertificateAuthorityInfoFromJSON ¶
func NewCertificateAuthorityInfoFromJSON(data []byte) (*CertificateAuthorityInfo, error)
func (*CertificateAuthorityInfo) Export ¶
func (n *CertificateAuthorityInfo) Export() ([]byte, error)
func (*CertificateAuthorityInfo) IncSerialNumber ¶
func (n *CertificateAuthorityInfo) IncSerialNumber()
type CertificateSigningRequest ¶
type CertificateSigningRequest struct {
// contains filtered or unexported fields
}
func NewCertificateSigningRequestFromDER ¶
func NewCertificateSigningRequestFromDER(derBytes []byte) *CertificateSigningRequest
NewCertificateSigningRequestFromDER inits CertificateSigningRequest from DER-format bytes
func NewCertificateSigningRequestFromPEM ¶
func NewCertificateSigningRequestFromPEM(data []byte) (*CertificateSigningRequest, error)
NewCertificateSigningRequestFromPEM inits CertificateSigningRequest from PEM-format bytes data should contain at most one certificate
func (*CertificateSigningRequest) CheckSignature ¶
func (c *CertificateSigningRequest) CheckSignature() error
CheckSignature verifies that the signature is a valid signature using the public key in CertificateSigningRequest.
func (*CertificateSigningRequest) Export ¶
func (c *CertificateSigningRequest) Export() ([]byte, error)
Export returns PEM-format bytes
func (*CertificateSigningRequest) GetCommonNameCertificateSigningRequest ¶
func (c *CertificateSigningRequest) GetCommonNameCertificateSigningRequest() (string, error)
func (*CertificateSigningRequest) GetRawCertificateSigningRequest ¶
func (c *CertificateSigningRequest) GetRawCertificateSigningRequest() (*x509.CertificateRequest, error)
GetRawCertificateSigningRequest returns a copy of this certificate request as an x509.CertificateRequest.
type Key ¶
type Key struct { Public crypto.PublicKey Private crypto.PrivateKey }
func CreateRSAKey ¶
CreateRSAKey creates a new Key using RSA algorithm
func NewKeyFromEncryptedPrivateKeyPEM ¶
NewKeyFromEncryptedPrivateKeyPEM inits Key from encrypted PEM-format rsa private key bytes
func NewKeyFromPrivateKeyPEM ¶
NewKeyFromPrivateKeyPEM inits Key from PEM-format rsa private key bytes
func (*Key) ExportEncryptedPrivate ¶
ExportEncryptedPrivate exports encrypted PEM-format private key
func (*Key) ExportPrivate ¶
ExportPrivate exports PEM-format private key