Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions src/Apache.IoTDB/SessionPool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Security.Cryptography.X509Certificates;
using System.Threading;
using System.Threading.Tasks;
Expand Down Expand Up @@ -450,9 +451,19 @@ public async Task<string> GetTimeZone()
private async Task<Client> CreateAndOpen(string host, int port, bool enableRpcCompression, int timeout, bool useSsl, string cert, string sqlDialect, string database, CancellationToken cancellationToken = default)
{

TTransport socket = useSsl ?
new TTlsSocketTransport(host, port, null, timeout, new X509Certificate2(File.ReadAllBytes(cert))) :
new TSocketTransport(host, port, null, timeout);
TTransport socket;
if (IPAddress.TryParse(host, out var ipAddress))
{
socket = useSsl
? new TTlsSocketTransport(ipAddress, port, null, timeout, new X509Certificate2(File.ReadAllBytes(cert)))
: new TSocketTransport(ipAddress, port, null, timeout);
}
else
{
socket = useSsl
? new TTlsSocketTransport(host, port, null, timeout, new X509Certificate2(File.ReadAllBytes(cert)))
: new TSocketTransport(host, port, null, timeout);
}

var transport = new TFramedTransport(socket);

Expand Down
Loading