OnixS C++ FIX Engine  4.10.1
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 std::string TargetCompID = "CNX";
const std::string Host = "TargetHost";
// Stream FIX Session.
{
const std::string StreamSenderCompID = "str";
const std::string StreamSslCertificateAndPrivateKeyFile = "str.pem";
Session streamSession(StreamSenderCompID, TargetCompID, ProtocolVersion::FIX_42, ONIXS_FIXENGINE_NULLPTR);
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.
const int StreamPort = 442;
streamSession.sslCertificateFile(StreamSslCertificateAndPrivateKeyFile)
.sslPrivateKeyFile(StreamSslCertificateAndPrivateKeyFile)
.logonAsInitiator(Host, StreamPort, 30, true);
std::clog << "Stream session is established." << std::endl;
streamSession.logout();
}
// Trading FIX Session.
{
const std::string TradingSenderCompID = "tr";
const std::string TradingSslCertificateAndPrivateKeyFile = "tr.pem";
Session tradingSession(TradingSenderCompID, TargetCompID, ProtocolVersion::FIX_42, ONIXS_FIXENGINE_NULLPTR);
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.
const int TradingPort = 443;
tradingSession.sslCertificateFile(TradingSslCertificateAndPrivateKeyFile)
.sslPrivateKeyFile(TradingSslCertificateAndPrivateKeyFile)
.logonAsInitiator(Host, TradingPort, 30, true);
std::clog << "Trading session is established." << std::endl;
tradingSession.logout();
}