v0.13.0-rc.0 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Aug 22, 2019 License: Apache-2.0 Imports: 16 Imported by: 0


This package is fork of golang/crypto/pkcs12.

Reason of fork:

Currently, pkcs12 can not decode a keystore if it has more than one key-cert pair. Ref:


There is already a pending PR here that introduce DecodeAll method that solve this issue. This forked version take the changes from that PR.

Use original package when is merged.



Package pkcs12 implements some of PKCS#12.

This implementation is distilled from and referenced documents. It is intended for decoding P12/PFX-stored certificates and keys for use with the crypto/tls package.



This section is empty.


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")


func Decode

func Decode(pfxData []byte, password string) (privateKey interface{}, certificate *x509.Certificate, err error)

Decode extracts a certificate and private key from pfxData. This function assumes that there is only one certificate and only one private key in the pfxData.

func DecodeAll

func DecodeAll(pfxData []byte, password string) (privateKeys []interface{}, certificates []*x509.Certificate, err error)

DecodeAll extracts all certificate and private keys from pfxData.

func ToPEM

func ToPEM(pfxData []byte, password string) ([]*pem.Block, error)

ConvertToPEM converts all "safe bags" contained in pfxData to PEM blocks.


type NotImplementedError

type NotImplementedError string

NotImplementedError indicates that the input is not currently supported.

func (NotImplementedError) Error

func (e NotImplementedError) Error() string


Path Synopsis
Package rc2 implements the RC2 cipher This code is licensed under the MIT license.
Package rc2 implements the RC2 cipher This code is licensed under the MIT license.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL