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

340
Visualizações
How to sign a text file using X509 certificate in Java?

I have exported a class 3 Digital certificate and I am able to get the details from the object named cert as seen below. I intend to sign a text file using this certificate. However since I exported this certificate without the private key, I am unable to proceed. I have shared a snippet below the image which has tags.

This is the file saved as .txt and the tags and will be the result of the signing process. So basically the raw payload will only have the other tags before the signing process.

My Questions:

  1. Am I on the right track to digitally sign the text file from backend?

  2. Should the access of the certificate be handled on the client side using Javascript

     try (InputStream inStream = new FileInputStream("D:\\New folder\\TestCertificate.cer")) {
          CertificateFactory cf = CertificateFactory.getInstance("X.509");
          X509Certificate cert = (X509Certificate)cf.generateCertificate(inStream);
    
          cert.checkValidity();
          System.out.println("This is public key :  " + cert.getPublicKey());
          System.out.println("This is certificate type: " + cert.getType());
    
          // Code to access a txt file and sign it with the certificate.
    
      } catch (CertificateException e) {
         // TODO Auto-generated catch block
         e.printStackTrace();
     } catch (FileNotFoundException e1) {
         // TODO Auto-generated catch block
         e1.printStackTrace();
     } catch (IOException e1) {
         // TODO Auto-generated catch block
         e1.printStackTrace();
     }
    

enter image description here

<MessageInfo>
<SenderIden>XSB000000000</SenderIden>
<SenderSP>100023193</SenderSP>
<Data><![CDATA[{IFN515}{XSB000000000}{XYZ12345} 
  {
  :16R:GENL
  :20C::SEME//A23P8W4
  :23G:NEWM
  :98A::PREP//20220221
  :22F::TRTR//TRAD
   ]]></Data>
  <SubscriberDS>MIIJuwYJKoZIhvcNAQcCoI</SubscriberDS>
  <ServiceProviderDS>MIIJuwYJKoZI</ServiceProviderDS>
  </MessageInfo>
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