This is a big question, especially regarding X.509 security. Usually with a self-signed certificate, you should import the source CA used to sign this certificate (usually the self-signed CA used by the application) into your key (to make sure that you are connecting to the correct server). This is usually required because your client application will check the connection if the certificate is signed by a known and trusted CA or matches an existing certificate in your chain.
In C #, you can check the System.Net.Security namespace and especially the SSlStream class for more details.
If you need to import a certificate into your keychain, you can use various interfaces to access keyring from the graphical user interface using the command line "Certutil.exe" or through various APIs .
Alexandre Dulaunoy
source share