Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

159
Visualizações
OpenPGP ^5.0.0-5 use public key from hardcoded string

This is not working for me, openPGP just freezes:

import openpgp from 'openpgp';

const publicKeyArmored = `-----BEGIN PGP PUBLIC KEY BLOCK-----

xjMEYLTYzBYJKwYBBAHaRw8BAQdAoatyco6C3CO87ZxgjIfWsFv3RMxs5W1F
EinwU2UiQ+bNF3Rlc3QgPHRlc3RAZXhhbXBsZS5vcmc+wowEEBYKAB0FAmC0
2MwECwkHCAMVCAoEFgACAQIZAQIbAwIeAQAhCRC+iM+wNlG7chYhBFZgyLBQ
Cavx4mET576Iz7A2UbtyVa8BAP1oFrSwoGdd7+dgBUu7KwU02wvrtuqyURe5
GFSTyMn2AQDWTsJjgYq7hPqSQoeZ30xN0eUoiUiyIA/ffqhM2qHPD844BGC0
2MwSCisGAQQBl1UBBQEBB0CxgKqNlcBTkuaFRvYm/UbR8ZKFFda0tnUCTzl/
tgCsJgMBCAfCeAQYFggACQUCYLTYzAIbDAAhCRC+iM+wNlG7chYhBFZgyLBQ
Cavx4mET576Iz7A2UbtysPgA/0pn4n3QqBBc56/okcGFdC78LEwDLN/ZLkY6
azfQ1aqwAP0d9CWw9ywheGtB1SBCzHZbToKaltVFCNT1ArSUFK45Dg==
=pnHg
-----END PGP PUBLIC KEY BLOCK-----
`;

let messageEncrypt = await openpgp.encrypt({
    message: await openpgp.createMessage({ text: 'test' }),
    publicKeys: await openpgp.readKeys({ armoredKey: publicKeyArmored }) // This promise never resolves
});

console.log(messageEncrypt);

However, if I read the key from disk using below approach it works:

import { readFileSync } from 'fs';
import openpgp from 'openpgp';

const armoredKeys = readFileSync('./public.key.asc', {
    encoding: 'utf8',
});

let messageEncrypt = await openpgp.encrypt({
    message: await openpgp.createMessage({ text: 'test' }),
    publicKeys: await openpgp.readKeys({ armoredKey: publicKeyArmored })
});

console.log(messageEncrypt); // Totally works

Since I'm eventually retrieving the key from AWS Secrets Manager I will have to treat it as a string and not a file on disk. I've tried using \n newline in the hardcoded string key, but doesn't make any difference.

What am I missing?

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda