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

339
Views
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
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!