code: function forgeObjectFromPem(input) {
      const msg = forge.pem.decode(input)[0];
      let key;
  
      switch (msg.type) {
          case 'PRIVATE KEY':
          case 'RSA PRIVATE KEY':
              key = forge.pki.privateKeyFromPem(input);
              break;
  
          case 'PUBLIC KEY':
          case 'RSA PUBLIC KEY':
              key = forge.pki.publicKeyFromPem(input);
              break;
  
          case 'CERTIFICATE':
          case 'X509 CERTIFICATE':
          case 'TRUSTED CERTIFICATE':
              key = forge.pki.certificateFromPem(input).publicKey;
              break;
  
          case 'CERTIFICATE REQUEST':
              key = forge.pki.certificationRequestFromPem(input).publicKey;
              break;
  
          default:
              throw new Error('Unable to detect forge message type');
      }
  
      return key;
  }
docs: Attempt to parse forge object from PEM encoded string
  
  @private
  @param {string} input PEM string
  @return {object}