Closed prashantguleria closed 7 months ago
I went through other issues and it's possible duplicate of : https://github.com/phax/as2-lib/issues/106
I'm not sure but the issue is similar.
Well, a keystore can contain "private keys" and "public certificates" besides other things. Are you sure one of them is a key. Use a tool like KeyStore Explorer (https://keystore-explorer.org/) and check the types of elements inside. Items with the icon are private keys - that is what you need for your key (and signing). However, items with the icon are public certificates and can only be used for encrypting for the receiver.
Thanks for taking your time to look into this.
Yes, I am sure that the pfx contains both certificate and corresponding private key. Check the screenshot below.
Also, I am using the same "pem" file with only certificate in receiver certificate code :
// Receiver details
settings.setReceiverData("RCVR", "RCVR", "https://prod-24.westus2.logic.azure.com:443/as2);
X509Certificate receiverCertificate = AS2KeyStoreHelper.readX509Certificate(drg_file);
settings.setReceiverCertificate(receiverCertificate);
However, when setting signAlgo this seems to go ahead without any issue.
settings.setEncryptAndSign(cryptAlgo, null);
After taking the suggestion from #106 I created a custom client and overriding getPrivateKey method, It's working fine.
Still I don't know if this is a good way forward.
Also, I wanted to ask if it's possible to add a custom alias to the certificate when creating a key store or setting a receiver certificate? When I checked the alias is fetched from friendly name present inside the
Bag Attributes
friendlyName: TEST
Thanks for remining me also on #106. I adopted the changes accordingly and will create a 5.1.2 release on it. hth
Hi phax,
I have been trying to use as2 lib for my use case. I generated a key valur pair using the open SSL and using the pfx file as sender certificate.
However, while sending the library is trying to find the key file for the receiver certificate and I am getting an exception that key doesn't exist.