How to configure LDAP/AD and SMIME certificate programmatically in MacMail and Outlook on Mac?

Hi ,


I have created a macOS app that fetches a certificate and key and imports it into the keychain. These certifcates can also be of S/MIME type , which are used for email authentication.

Now what I want to do is, whenever S/MIME certificate is encountered , this certificate should be automatically set as the applicable email encryption (S/MIME) certificate for MacMail and Outlook , also its LDAP/AD is configured in both MacMail and Outlook.


Is there a way to programmatically configure a particular certificate for encryption in Outlook and MacMail?

Any Swift code, tutorial ,project or terminal command would be helpful.


Regards,

Souvanik.