Session-level TLS/SSL Settings
OnixS .NET FIX Engine provides an ability to localize TLS/SSL-related attributes to the bounds of a single FIX Session.
Per-session TLS/SSL settings can be accessed via the Ssl property.
Note
Per-session TLS/SSL settings are supported only for sessions-initiators. Session-acceptors can work only with global FIX Engine TLS/SSL settings.
For example:
const string targetCompID = "CNX";
const string host = "TargetHost";
// Stream FIX Session.
{
const string streamSenderCompID = "str";
var streamSession = new Session(streamSenderCompID, targetCompID, ProtocolVersion.Fix44)
{
Encryption = EncryptionMethod.Ssl
};
// If your counterparty performs the verification of your TLS/SSL certificate
// you need to set the TLS/SSL Certificate File.
string streamSslCertificateAndPrivateKeyFile = "str.pfx";
streamSession.Ssl.CertificateLocation = streamSslCertificateAndPrivateKeyFile;
const int streamPort = 442;
streamSession.LogonAsInitiator(host, streamPort, 30, true);
}
// Trading FIX Session.
{
const string tradingSenderCompID = "tr";
var tradingSession = new Session(tradingSenderCompID, targetCompID, ProtocolVersion.Fix44)
{
Encryption = EncryptionMethod.Ssl
};
string tradingSslCertificateAndPrivateKeyFile = "tr.pfx";
// If your counterparty performs the verification of your TLS/SSL certificate
// you need to set the TLS/SSL Certificate File.
tradingSession.Ssl.CertificateLocation = tradingSslCertificateAndPrivateKeyFile;
int tradingPort = 443;
tradingSession.LogonAsInitiator(host, tradingPort, 30, true);
}