webMethods Integration Server package for PGP


I’m trying to implement the GitHub PGP package (https://github.com/SoftwareAG/webmethods-integrationserver-pgpencryption), but getting errors while running the readPublicKeys and getPrivateKeys. Fixed readPublicKeys by modifying the below step by referring the pgp_idk.jar

GitHub Code : keyPub = PGPKeyReader.readPublicKey(ringPub,PGPInit.getKeyExchangeAlgorithm(alg));
Modified Code : keyPub = PGPKeyReader.readPublicKey(path,PGPInit.getKeyExchangeAlgorithm(alg));

Unable to fix the getPrivateKeys service, getting the error “Private key ring is empty” while running testDecryptFile service.

[I]getPrivateKeys is only returning “privateKeyRing” as per the GitHub code. I fixed this service to return all the output parameters by changing the code entirely(attached), still testDecryptFile is throwing the same error. Can someone help me with this?
modifiedgetPrivateKeys.java (3.22 KB)

Is your private key in a key file or keyring file?
It can’t be both, so these two lines:
ringSecret = PGPKeyReader.readSecretKeyRing(path);
keySecret = PGPKeyReader.readSecretKey(path);
only one should be called.

Hi Tong,

Thanks for your reply.

Actually the only requirement of this java service is to get the secretKeyRing. I modified the service only to get this, still the decryptandVerify service in throws the error “Private key ring is empty”.

Modified Service:
String path = IDataUtil.getString(pc, “path”);
IData data = IDataFactory.create();
PGPSecretKeyRingCollection secretKeyRing = null;
try {
IDataCursor dc = data.getCursor();
secretKeyRing = PGPKeyReader.readSecretKeyRing(path);
IDataUtil.put(dc, “privateKeyRing”, secretKeyRing);
} catch (Exception e) {
throw new RuntimeException("Unable to read private key file: " + e.getMessage());

	IDataUtil.put(pc, "privateKeyData", data);

Also attached the output of this modified java service