SSL Connect Error

Development language: .NET C#,
ISession session = context.CreateSession(sessionProps, null, null)
result: Failed to create session
code:
SessionProperties sessionProps = new SessionProperties()
{
Host = “tcps://solace-test.zjhwmy.com.cn:55443”, //host,//“smfs://solace-test.zjhwmy.com.cn:55443”,
VPNName = vpnnane, //“Preprod”,
UserName = username, //“test-user-mes”,
Password = password, //“Aa112211”,
ReconnectRetries = DefaultReconnectRetries,
// Option to disbale validating of certificate
SSLValidateCertificate = true,

};
ISession session = context.CreateSession(sessionProps, null, null);

Hi there, I’m Solly AI, I generate responses to your questions using the power of the Solace Agent Mesh:

Please remember that AI technology can make mistakes so ensure that you read our Disclaimer.

AI Generated responses are a work in progress, your help in evaluating my response would be awesome! If my response makes sense, please mark it as a solution or give a :+1:. If my response doesn’t make sense for your topic, please react to it with a :shaking_face:.

Looking at the documentation and community discussions, here’s how to resolve the session creation failure:

The error is likely related to SSL/TLS certificate validation when connecting to a secured port. There are two main approaches to resolve this:

  1. Disable certificate validation (less secure, but simpler):
SessionProperties sessionProps = new SessionProperties() {
    Host = host,
    VPNName = vpnName,
    UserName = userName,
    Password = password,
    SSLValidateCertificate = false
};
  1. Configure proper certificate validation by loading certificates from the system certificate store:
SessionProperties sessionProps = new SessionProperties() {
    Host = host,
    VPNName = vpnName,
    UserName = userName,
    Password = password,
    SSLTrustStore = certificatesCollection  // Collection of trusted certificates
};

Additional considerations:

  • Make sure you’re using the correct secure port (55443) for TCPS connections
  • Set appropriate reconnect properties if needed:
    • ReconnectRetries
    • ConnectRetriesPerHost
    • ConnectTimeoutInMsecs

Relevant documentation:

modify code:
SessionProperties sessionProps = new SessionProperties()
{
Host = “tcps://solace-test.zjhwmy.com.cn:55443”, //host,//“smfs://solace-test.zjhwmy.com.cn:55443”,
VPNName = vpnnane, //“Preprod”,
UserName = username, //“test-user-mes”,
Password = password, //“Aa112211”,
ReconnectRetries = DefaultReconnectRetries,
// Option to disbale validating of certificate
SSLValidateCertificate = false,

};
SolaceSystems.Solclient.Messaging.ISession session = context.CreateSession(sessionProps, null, null);
ReturnCode returnCode = session.Connect();
result:Failed to connect session

You need to specify the SSL Trust Store location

Host = “tcps://solace-test.zjhwmy.com.cn:55443”, 
VPNName = vpnnane, //“Preprod”,
UserName = username, //“test-user-mes”,
Password = password, //“Aa112211”,
ReconnectRetries = DefaultReconnectRetries,
// Option to disbale validating of certificate
SSLValidateCertificate = false,
//specify the SSL Trust Store location, for example
SSLTrustStoreDir = AppDomain.CurrentDomain.BaseDirectory

In this case, you should put the trust store in the same directory as your application