How to decrypt S/MIME?

The example at https://www.example-code.com/xojo/smime_verify_signature.asp shows how to decrypt S/MIME. But I think it glosses a bit on how to use the Cert part. Can’t I have multiple certificates? Do I need to find the correct certificate or is this handled automatically?

I have some SMIME functions in OpenSSLMBS module. Please take a look.

Here is the example code for decrypting:

[code] dim c as X509MBS = X509MBS.Open(ReadFile(GetFolderItem(“signer.pem”)))
dim k as PKeyMBS = PKeyMBS.Open(ReadFile(GetFolderItem(“signer.pem”)))
dim i as string = ReadFile(GetFolderItem(“smencr.txt”))

		dim d as string = OpenSSLMBS.SMimePKCS7Decrypt(i, c, k)
		
		WriteFile d, GetFolderItem("encrout.txt")[/code]

Where do I get signer.pem? Isn’t this what Cert from the Chilkat plugin manages?

with our plugin you can read PKCS#12 file to get both private key and certificates.
Or you have them in a pem file like in the example.
Or you have them in separate files.

I’m a total newbie in this email encryption stuff. Where do I get the pem file? Doesn’t the mail client manage these files? Shouldn’t the keychain handle the encryption?