Hi @Arash Ghadakchi ,Welcome to Microsoft Q&A,
If you use IP direct connection, you can connect. This could be due to several reasons, such as the SSL certificate not being trusted or not being configured correctly.
You can try this experience-filled post:The request was aborted: Could not create SSL/TLS secure channel
You can try the following example:
using System;
using System.ServiceModel;
using System.ServiceModel.Description;
namespace xxx
{
internal class Program
{
static void Main(string[] args)
{
// Specify the base address of your service
Uri baseAddress = new Uri("https://yourdomain.com/YourService");
// Create a ServiceHost instance
using (ServiceHost host = new ServiceHost(typeof(YourService), baseAddress))
{
try
{
// Enable metadata publishing
ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
smb.HttpsGetEnabled = true;
host.Description.Behaviors.Add(smb);
// Specify the binding with SSL
BasicHttpsBinding binding = new BasicHttpsBinding();
// Enable SSL certificate validation
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;
// Add the endpoint
host.AddServiceEndpoint(typeof(IYourService), binding, "");
// Open the ServiceHost to start listening for messages
host.Open();
Console.WriteLine("The service is ready at {0}", baseAddress);
Console.WriteLine("Press <Enter> to stop the service.");
Console.ReadLine();
// Close the ServiceHost
host.Close();
}
catch (Exception ex)
{
Console.WriteLine("An error occurred: {0}", ex.Message);
host.Abort();
}
}
}
}
// Define your service contract and implementation
[ServiceContract]
public interface IYourService
{
[OperationContract]
string YourMethod();
}
public class YourService : IYourService
{
public string YourMethod()
{
return "Hello, World!";
}
}
}
Replace "https://yourdomain.com/YourService" with your actual HTTPS endpoint. Enabled ServiceMetadataBehavior to publish metadata over HTTPS. BasicHttpsBinding is used to configure basic HTTPS binding. binding.Security.Transport.ClientCredentialType Set to HttpClientCredentialType.None to disable SSL certificate verification for the client credential type. Replace YourMethod with your actual service method. Make sure you have a valid SSL certificate installed on your server and configured correctly. Also, make sure your clients trust the SSL certificate authority.
Best Regards,
Jiale
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.