{"record":{"id":"80286896cdf91d37","repo":"hyperledger/fabric","slug":"marshalling-of-the-certificate-failed","errorCode":null,"errorMessage":"marshalling of the certificate failed","messagePattern":"marshalling of the certificate failed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"msp/cert.go","lineNumber":111,"sourceCode":"\t// otherwise create a new certificate with the new signature\n\n\t// 1. Unmarshal cert.Raw to get an instance of certificate,\n\t//    the lower level interface that represent an x509 certificate\n\t//    encoding\n\tvar newCert certificate\n\tnewCert, err = certFromX509Cert(cert)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// 2. Change the signature\n\tnewCert.SignatureValue = asn1.BitString{Bytes: expectedSig, BitLength: len(expectedSig) * 8}\n\tnewCert.Raw = nil\n\n\t// 3. marshal again newCert. Raw must be nil\n\tnewRaw, err := asn1.Marshal(newCert)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"marshalling of the certificate failed\")\n\t}\n\n\t// 4. parse newRaw to get an x509 certificate\n\treturn x509.ParseCertificate(newRaw)\n}\n\nfunc certFromX509Cert(cert *x509.Certificate) (certificate, error) {\n\tvar newCert certificate\n\t_, err := asn1.Unmarshal(cert.Raw, &newCert)\n\tif err != nil {\n\t\treturn certificate{}, errors.Wrap(err, \"unmarshalling of the certificate failed\")\n\t}\n\treturn newCert, nil\n}\n\n// String returns a PEM representation of a certificate\nfunc (c certificate) String() string {\n\tb, err := asn1.Marshal(c)","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/msp/cert.go#L93-L129","documentation":"sanitizeECDSASignedCert: after replacing the ECDSA signature value with the low-S variant, re-encoding the modified certificate structure with encoding/asn1.Marshal failed; the wrapped error describes the ASN.1 encoding failure.","triggerScenarios":"Thrown at msp/cert.go:111 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the wrapped asn1 error for the offending field","Verify the certificate is well-formed before sanitization","Report upstream if a valid cert cannot be re-marshalled"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2736b63f8fd5932511d56fe68b7039d15977f7f6","analyzedAt":"2026-09-04T08:52:36.465Z","contentChangedAt":"2026-09-04T08:52:36.465Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}