- Eric Nieva
- PowerBuilder
- Monday, 5 October 2020 12:51 AM UTC
I am trying to generate the payload for a rest API and part of the payload is a digital signature using our private key.
The private key is generated from an external source using openssl, with AES-256 encryption as below:
openssl genrsa -aes256 -passout pass:{password} -out {location} 2048
and then converted to PKCS#8 format also using openssl.
I am using the CrypterObject AsymmetricSign function to generate the signature using the PKCS#8 private key but I get an Invalid privKey error.
Does PB2019 support encrypted private keys for AsymmetricSign? If so, are there additional steps that need to be done before I call this function?
Thanks,
Eric
Below is the sample code:
String ls_private_key_pkcs8
Blob lblb_private_key, lblb_hash, lblb_sign
CrypterObject lnv_CrypterObject
CoderObject lnv_CoderObject
lnv_CrypterObject = Create CrypterObject
lnv_CoderObject = Create CoderObject
ls_private_key_pkcs8 = 'MIIFLTBXBgkqhkiG9w0BBQ0wSjApBgkqhkiG9w0BBQwwHAQI77MkcuVWINQCAggA'
ls_private_key_pkcs8 += 'MAwGCCqGSIb3DQIJBQAwHQYJYIZIAWUDBAEqBBD3UscJJMjByZaOQnhrEXF1BIIE'
ls_private_key_pkcs8 += '0LygIgD3de0dMf9zvPnaNEMG2JNZow42DQjN7EOo+ni4blH+AgYB1jWzH+1BWkQn'
…
…
…
lblb_private_key = lnv_CoderObject.Base64Decode(ls_private_key_pkcs8)
lblb_hash = lnv_CrypterObject.SHA(SHA256!, Blob('Key=Value', EncodingUTF8!))
lblb_sign = lnv_CrypterObject.AsymmetricSign(RSA!, lblb_hash, lblb_private_key)
Find Questions by Tag
Helpful?
If a reply or comment is helpful for you, please don’t hesitate to click the Helpful button. This action is further confirmation of their invaluable contribution to the Appeon Community.