Documentation
¶
Overview ¶
Package pkcs12 provides some implementations of PKCS#12.
This implementation is distilled from https://tools.ietf.org/html/rfc7292 and referenced documents. It is intended for decoding P12/PFX-stored certificate+key for use with the crypto/tls package.
Index ¶
- Constants
- Variables
- func ConvertToPEM(pfxData, utf8Password []byte) (blocks []*pem.Block, err error)
- func Create(certificate, privatekey, password []byte, calist [][]byte) ([]byte, error)
- func CreateEtc(certificate, privatekey, password []byte, calist [][]byte, ...) ([]byte, error)
- func Decode(pfxData, utf8Password []byte) (privateKey interface{}, certificate *x509.Certificate, err error)
- type AsnItem
- func AsnCC(n int) *AsnItem
- func AsnCCRaw(n int, data []byte) *AsnItem
- func AsnContainer(_tag int) *AsnItem
- func AsnInteger(i int) *AsnItem
- func AsnNull() *AsnItem
- func AsnOID(oid []byte) *AsnItem
- func AsnOctetString(data []byte) *AsnItem
- func AsnOctetStringContainer() *AsnItem
- func AsnRaw(_tag int, _data []byte) *AsnItem
- func AsnSequence() *AsnItem
- func AsnSet() *AsnItem
- func AsnString(s string) *AsnItem
- type NotImplementedError
Examples ¶
Constants ¶
View Source
const ( TagEndOfContent = 0x00 TagBoolean = 0x01 TagInteger = 0x02 TagBitString = 0x03 TagOctetString = 0x04 TagNull = 0x05 TagOID = 0x06 TagUTF8String = 0x0C TagSequence = 0x10 TagSet = 0x11 TagPrintableString = 0x13 TagUTCTime = 0x17 ClassUniversal = 0x00 ClassApplication = 0x40 ClassContextSpecific = 0x80 ClassPrivate = 0xC0 TypeConstructed = 0x20 )
View Source
const ( CertificateType = "CERTIFICATE" PrivateKeyType = "PRIVATE KEY" )
PEM block types
Variables ¶
View Source
var ( // ErrDecryption represents a failure to decrypt the input. ErrDecryption = errors.New("pkcs12: decryption error, incorrect padding") // ErrIncorrectPassword is returned when an incorrect password is detected. // Usually, P12/PFX data is signed to be able to verify the password. ErrIncorrectPassword = errors.New("pkcs12: decryption password incorrect") )
Functions ¶
func ConvertToPEM ¶
ConvertToPEM converts all "safe bags" contained in pfxData to PEM blocks.
Example ¶
var p12, _ = base64.StdEncoding.DecodeString(`MIIJzgIBAzCCCZQGCS ... CA+gwggPk==`) blocks, err := ConvertToPEM(p12, []byte("password")) if err != nil { panic(err) } pemData := []byte{} for _, b := range blocks { pemData = append(pemData, pem.EncodeToMemory(b)...) } // then use PEM data for tls to construct tls certificate: cert, err := tls.X509KeyPair(pemData, pemData) if err != nil { panic(err) } config := tls.Config{ Certificates: []tls.Certificate{cert}, } config.BuildNameToCertificate() for name := range config.NameToCertificate { fmt.Println(name) }
Output:
Types ¶
type AsnItem ¶
type AsnItem struct {
// contains filtered or unexported fields
}
func AsnContainer ¶
func AsnInteger ¶
func AsnOctetString ¶
func AsnOctetStringContainer ¶
func AsnOctetStringContainer() *AsnItem
func AsnSequence ¶
func AsnSequence() *AsnItem
type NotImplementedError ¶
type NotImplementedError string
NotImplementedError indicates that the input is not currently supported.
func (NotImplementedError) Error ¶
func (e NotImplementedError) Error() string
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
internal
|
|
rc2
Package rc2 implements the RC2 cipher https://www.ietf.org/rfc/rfc2268.txt http://people.csail.mit.edu/rivest/pubs/KRRR98.pdf This code is licensed under the MIT license.
|
Package rc2 implements the RC2 cipher https://www.ietf.org/rfc/rfc2268.txt http://people.csail.mit.edu/rivest/pubs/KRRR98.pdf This code is licensed under the MIT license. |
Click to show internal directories.
Click to hide internal directories.