Get signature and certification path from PFX

General Tech QA/Testing 2 years ago

0 1 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating

Posted on 16 Aug 2022, this text provides information on QA/Testing related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (1)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 2 years ago

 

I have a SOAP message like

<soapenv:Envelope
    xmlns:soapenv = "http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:v = "http://www.something.com">
    <soapenv:Header/>
    <soapenv:Body>
        <v:Auth>
            <v:userID>xxxxxxxxxxv:userID>
            <v:password>xxxxxxxxxxv:password>
            <v:certChain>xxxxxxxxxxv:certChain>
            <v:signature>xxxxxxxxxxv:signature>
        v:Auth>
    soapenv:Body>
soapenv:Envelope>

After generating the java source code from WSDL, for Auth, I am setting value like this. (all the below 4 fields are string datatype)

Auth authInfo = new Auth();
authInfo.setUserID(userId);
authInfo.setPassword(password);
authInfo.setCertChain("");
authInfo.setSignature("");

The following is the piece of code using which I get signature, digest value, certificate chain. But when I populate the values and submit the SOAP message I get a Digital Signature Invalid Error. But I verified that the signature is valid.

Code to extract the details:

I face issue with getting certification path and signature from pfx file. Can you share the code which gets them, I have the following piece of code to get them. When I use the signature and certification path obtained through below code , I always get Invalid Digital signature.

public void getCertificateDetails(){
    String aliasName="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; // not posted here

    try{ 

         char[] passwd = KEY_STORE_PASSWORD.toCharArray();          

         keyStore = KeyStore.getInstance("PKCS12","SunJSSE");


         FileInputStream fis = new FileInputStream("path to pfx file");
         keyStore.load(fis, passwd);

         fis.close();

         Enumeration aliases;


         Certificate[] cc =  keyStore.getCertificateChain(aliasName);
         X509Certificate certificate1 = (X509Certificate) cc[0];

         System.out.println("signo algo:"+certificate1.getSigAlgName()); // get the value as SHA256withRSA

         PrivateKey pKey = (PrivateKey)keyStore.getKey("xxxxxxxxxxxxxxxxxxxxxxxxx", passwd);
                                                
                                                
0 views
0 shares

No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.