Click or drag to resize

Transmitter5SetReceiverCertificate Method

Tell the SwissDecTX Transmitter what certificate to use to crypt the transmissions, this is the server's certificate and the server's public key it contains is used for encrypting outgoing messages. This call overrides the configured receiver certificate and can be used to switch programmatically between a test and a production certificate.

Namespace: SwissDecTX
Assembly: SwissDecTX.Transmitter5 (in SwissDecTX.Transmitter5.dll) Version: 5.0.0.0 (5.0.0.0)
Syntax
public void SetReceiverCertificate(
	string certificateSearchString,
	Transmitter5CertificateSearchMode certificateSearchMode
)

Parameters

certificateSearchString  String
The string to be used to locate the certificate (depends on the search mode).
certificateSearchMode  Transmitter5CertificateSearchMode
The search mode to be used to find the certificate, see Transmitter5CertificateSearchMode.
Remarks
It is not mandatory to call this method, you can configure the receiver certificate using the SwissDecTX configuration tool. The certificate to be used here has to be issued by SwissDec and must not contain a private key. Use the InstallCertificates(String, String, String, String, Boolean) method to install the certificates you got from SwissDec in the computer. This method call only affects the current transmitter instance.
Example
Calling Transmitter.SetReceiverCertificate()
   using SwissDecTX;

// ...

       try {

           var tx = new Transmitter5();

           if (useTestCertificates) {
               tx.SetReceiverCertificate("SERIALNUMBER=4, CN=RefApp Receiver, O=Swissdec, C=CH", CertificateSearchMode.FindBySubjectDistinguishedName);
           } else {
               tx.SetReceiverCertificate("C=CH, O=Swissdec, CN=Distributor", CertificateSearchMode.FindBySubjectDistinguishedName);
           }

           // TODO: Set the transmitter certificate if needed

           // TODO: Use the transmitter...

       } catch (Exception ex) {

           MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

       }
See Also