func UnmarshalPemData(pemData []byte) ([]*x509.Certificate, []crypto.Signer, error) {
	var (
		block *pem.Block
		rest  = pemData
	)

	certificates := []*x509.Certificate{}
	signers := []crypto.Signer{}

	for {
		block, rest = pem.Decode(rest)
		if block == nil {
			break
		}

		switch blockType := block.Type; blockType {
		case PEMTypeCertificate:
			cert, err := x509.ParseCertificate(block.Bytes)
			if err != nil {
				return nil, nil, errors.Annotate(err, "parsing pem certificate block")
			}
			certificates = append(certificates, cert)
		case PEMTypePKCS8:
			signer, err := UnmarshalSignerFromPemBlock(block)
			if err != nil {
				return nil, nil, errors.Annotate(err, "parsing pem private key block")
			}
			signers = append(signers, signer)
		case PEMTypePKCS1:
			signer, err := UnmarshalSignerFromPemBlock(block)
			if err != nil {
				return nil, nil, errors.Annotate(err, "parsing pem private key block")
			}
			signers = append(signers, signer)
		default:
			return nil, nil, errors.NotSupportedf("block type %s", blockType)
		}
	}
	return certificates, signers, nil
}
// UnmarshalPemData unmarshals a set of pem data into certificates and signers
UnmarshalPemData unmarshals a set of pem data into certificates and signers
// UnmarshalPemData unmarshals a set of pem data into certificates and signers
func UnmarshalPemData(pemData []byte) ([]*x509.Certificate, []crypto.Signer, error) {
	var (
		block *pem.Block
		rest  = pemData
	)
	certificates := []*x509.Certificate{}
	signers := []crypto.Signer{}
	for {
		block, rest = pem.Decode(rest)
		if block == nil {
			break
		}
		switch blockType := block.Type; blockType {
		case PEMTypeCertificate:
			cert, err := x509.ParseCertificate(block.Bytes)
			if err != nil {
				return nil, nil, errors.Annotate(err, "parsing pem certificate block")
			}
			certificates = append(certificates, cert)
		case PEMTypePKCS8:
			signer, err := UnmarshalSignerFromPemBlock(block)
			if err != nil {
				return nil, nil, errors.Annotate(err, "parsing pem private key block")
			}
			signers = append(signers, signer)
		case PEMTypePKCS1:
			signer, err := UnmarshalSignerFromPemBlock(block)
			if err != nil {
				return nil, nil, errors.Annotate(err, "parsing pem private key block")
			}
			signers = append(signers, signer)
		default:
			return nil, nil, errors.NotSupportedf("block type %s", blockType)
		}
	}
	return certificates, signers, nil
}
func UnmarshalPemData ( pemData [ ] byte ) ( [ ] * x509 . Certificate , [ ] crypto . Signer , error ) { var ( block * pem . Block rest = pemData ) certificates := [ ] * x509 . Certificate { } signers := [ ] crypto . Signer { } for { block , rest = pem . Decode ( rest ) if block == nil { break } switch blockType := block . Type ; blockType { case PEMTypeCertificate : cert , err := x509 . ParseCertificate ( block . Bytes ) if err != nil { return nil , nil , errors . Annotate ( err , " " ) } certificates = append ( certificates , cert ) case PEMTypePKCS8 : signer , err := UnmarshalSignerFromPemBlock ( block ) if err != nil { return nil , nil , errors . Annotate ( err , " " ) } signers = append ( signers , signer ) case PEMTypePKCS1 : signer , err := UnmarshalSignerFromPemBlock ( block ) if err != nil { return nil , nil , errors . Annotate ( err , " " ) } signers = append ( signers , signer ) default : return nil , nil , errors . NotSupportedf ( " " , blockType ) } } return certificates , signers , nil }
UnmarshalPemData unmarshals a set of pem data into certificates and signers
UnmarshalPemData unmarshals a set of pem data into certificates and signers