SAP AS Java provides a keystore to manage public certificates and private keys used to digitally-sign, encode, decode and validate messages. Unfortunately accessing the key storage from a SAP PI/PO adapter module is not fully covered by SAP documentation and can pose a challenge.
The code snippet below retrieves a reference to interface ISsfProfile. Once you retrieve the reference you can call methods getPrivateKey and getCertificate to access the private key and the public certificate respectively.
Copy the provided methods to your Adapter Module class. Replace sap.com/modules.pi.XMLDSig in line 10 with your module’s bean name.
Keystore View and Keystore Entry are retrieved from Adapter Module’s parameters (in my module they are named keystoreView and keystoreEntry, but you can choose any other names). The parameters are read with a helper method getParameterValue. Make sure the parameters are maintained in the Communication Channel in Integration Directory.
To be able to compile the code you have to add com.sap.security_2.0.0*.jar (* is a version number and can be different on your system) to your project’s classpath in NWDS. You’ll find the jar in your NWDS installation path in plugins folder (e.g. com.sap.security_22.214.171.124803115025.jar)