diff --git a/uzi_vc_issuer/ura_issuer.go b/uzi_vc_issuer/ura_issuer.go index a716827..c7beaa8 100644 --- a/uzi_vc_issuer/ura_issuer.go +++ b/uzi_vc_issuer/ura_issuer.go @@ -6,7 +6,6 @@ import ( "crypto/sha1" "crypto/x509" "encoding/base64" - "encoding/pem" "errors" "fmt" "github.com/nuts-foundation/go-did/did" @@ -172,7 +171,7 @@ func BuildUraVerifiableCredential(chain []*x509.Certificate, signingKey *rsa.Pri func marshalChain(certificates ...*x509.Certificate) (*cert.Chain, error) { chainPems := &cert.Chain{} for _, certificate := range certificates { - err := chainPems.Add(pem.EncodeToMemory(&pem.Block{Type: "CERTIFICATE", Bytes: certificate.Raw})) + err := chainPems.Add([]byte(base64.StdEncoding.EncodeToString(certificate.Raw))) if err != nil { return nil, err } diff --git a/uzi_vc_validator/ura_validator.go b/uzi_vc_validator/ura_validator.go index 57a0bb3..56df085 100644 --- a/uzi_vc_validator/ura_validator.go +++ b/uzi_vc_validator/ura_validator.go @@ -12,7 +12,6 @@ import ( "github.com/nuts-foundation/go-did/vc" "github.com/nuts-foundation/uzi-did-x509-issuer/ca_certs" "github.com/nuts-foundation/uzi-did-x509-issuer/did_x509" - pem2 "github.com/nuts-foundation/uzi-did-x509-issuer/pem" "github.com/nuts-foundation/uzi-did-x509-issuer/x509_cert" ) @@ -192,16 +191,17 @@ func parseCertificate(chain *cert.Chain) ([]*x509.Certificate, error) { var certificates []*x509.Certificate for i := 0; i < chain.Len(); i++ { bytes, _ := chain.Get(i) - blocks := pem2.ParsePemBlocks(bytes, "CERTIFICATE") - for _, block := range blocks { - found, err := x509.ParseCertificates(block) - if err != nil { - return nil, err - } - for _, c := range found { - if c != nil { - certificates = append(certificates, c) - } + der, err := base64.StdEncoding.DecodeString(string(bytes)) + if err != nil { + return nil, err + } + found, err := x509.ParseCertificates(der) + if err != nil { + return nil, err + } + for _, c := range found { + if c != nil { + certificates = append(certificates, c) } } }