Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

667
Views
Convert certificate in p12 file to base64

I have a p12 certificate which I need to use to create digital signatures to be sent in the headers of a HTTP request. I'm using the node-forge package to get the privateKey and certificate bags from the p12.

const p12Asn1 = forge.asn1.fromDer(keyFile)
const p12 = forge.pkcs12.pkcs12FromAsn1(p12Asn1, passwordHash)
const certificateBags = p12.getBags({ bagType: forge.pki.oids.certBag })
const certificate = certificateBags[forge.pki.oids.certBag][0].cert

I have instructions from the API vendor on creating the digital signature. One step is:

keyId - Get X509 certificate that accompanies the private key as a byte array and Base64 encode. This field is required.

How can I Base64 encode the certificate extracted from the bags above? I have tried various forge utility methods, forge.util, but the certificate is an object at this point so I'm not sure what bit needs encoding.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!