PowerBuilder
PowerBuilder
Example: Mime.GetDecryptCertInfo method
Demonstrates theGetDecryptCertInfo method.
Chilkat PowerBuilder Downloads
integer li_rc
integer li_Success
oleobject loo_Mime
oleobject loo_Json
string ls_Serial
string ls_IssuerCN
integer i
integer li_Count
li_Success = 0
loo_Mime = create oleobject
li_rc = loo_Mime.ConnectToNewObject("Chilkat.Mime")
if li_rc < 0 then
destroy loo_Mime
MessageBox("Error","Connecting to COM object failed")
return
end if
// Load MIME that is has Content-Type like this:
// Content-Type: application/pkcs7-mime; smime-type="enveloped-data"; name="smime.p7m"; smime-type="enveloped-data"
li_Success = loo_Mime.LoadMimeFile("qa_data/mime/enveloped_data.eml")
if li_Success = 0 then
Write-Debug loo_Mime.LastErrorText
destroy loo_Mime
return
end if
// Get information about the certificate that would be needed to decrypt.
// An enveloped-data can potentially be decrypted by multiple certificates if it was encrypted in a way that allows it,
// but in most cases, only a single certificate with associated private key (that of the message recipient) is possible.
loo_Json = create oleobject
li_rc = loo_Json.ConnectToNewObject("Chilkat.JsonObject")
li_Success = loo_Mime.GetDecryptCertInfo(loo_Json)
if li_Success = 0 then
Write-Debug loo_Mime.LastErrorText
destroy loo_Mime
destroy loo_Json
return
end if
loo_Json.EmitCompact = 0
Write-Debug loo_Json.Emit()
// Sample output:
// {
// "recipientInfo": [
// {
// "serial": "****",
// "issuerCN": "****"
// }
// ]
// }
// Get each certificate's information like this:
i = 0
li_Count = loo_Json.SizeOfArray("recipientInfo")
do while i < li_Count
loo_Json.I = i
ls_Serial = loo_Json.StringOf("recipientInfo[i].serial")
ls_IssuerCN = loo_Json.StringOf("recipientInfo[i].issuerCN")
i = i + 1
loop
destroy loo_Mime
destroy loo_Json