OnixS C++ FIX Engine  4.0.0
API Documentation
Per-session TLS/SSL Settings

The OnixS C++ 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, using OnixS::FIX::Session::sslCertificateFile and OnixS::FIX::Session::sslPrivateKeyFile members of the OnixS::FIX::Session class.

Note
Per-session TLS/SSL settings are supported only for initiator sessions. Acceptor sessions can work only with global FIX Engine TLS/SSL settings.

Example

const string targetCompID = "CNX";
const string host = "TargetHost";
// Stream FIX Session.
{
const string streamSenderCompID = "str";
const string streamSslCertificateAndPrivateKeyFile = "str.pem";
Session streamSession(streamSenderCompID, targetCompID, ProtocolVersion::FIX_42, NULL);
streamSession.encryptionMethod(EncryptionMethod::SSL);
// If your counterparty performs the verification of your TLS/SSL certificate,
// you need to set both TLS/SSL Certificate File and TLS/SSL Private Key File.
streamSession.sslCertificateFile(streamSslCertificateAndPrivateKeyFile);
streamSession.sslPrivateKeyFile(streamSslCertificateAndPrivateKeyFile);
const int streamPort = 442;
streamSession.logonAsInitiator(host, streamPort, 30, true);
std::clog << "Stream session is established." << std::endl;
streamSession.logout();
}
// Trading FIX Session.
{
const string tradingSenderCompID = "tr";
const string tradingSslCertificateAndPrivateKeyFile = "tr.pem";
Session tradingSession(tradingSenderCompID, targetCompID, ProtocolVersion::FIX_42, NULL);
tradingSession.encryptionMethod(EncryptionMethod::SSL);
// If your counterparty performs the verification of your TLS/SSL certificate,
// you need to set both TLS/SSL Certificate File and TLS/SSL Private Key File.
tradingSession.sslCertificateFile(tradingSslCertificateAndPrivateKeyFile);
tradingSession.sslPrivateKeyFile(tradingSslCertificateAndPrivateKeyFile);
const int tradingPort = 443;
tradingSession.logonAsInitiator(host, tradingPort, 30, true);
std::clog << "Trading session is established." << std::endl;
tradingSession.logout();
}