title: NodeJS load PFX certificate from file
body: <p>I am writing a small project using Node.JS and TypeScript, once of the requirements is to read a PFX certificate from a .pfx file and use this in the code to encrypt the payload body</p>
  
  <p>I have a certificate public/private key file called <code>cert1.pfx</code>, my code requires this certificate as below</p>
  
  <pre><code>...
  const cert = loadPfx("cert1.pfx");
  const p: Payload = new Payload();
  p.addReaderCertificate(cert);
  ...
  </code></pre>
  
  <p>I have searched around but cannot find a way to load the PFX for my use case, I have seen examples of loading a PFX for HTTPS server or Express.JS, I looked a node-x509 but that is for BASE64 encoded CER or PEM certificates, I also looked at node-rsa but thats for encrypt/decrypt using public/private keys.</p>
  
  <p>Does anyone know if this is possible? If so would appreciate some pointers on how to accomplish.</p>