how to resolve web service error log

Arash Ghadakchi 20 Reputation points

Hello. i wrote a c# web service which works via ip address but when i redirect my address to an encrypted mode (SSL) , the ip does not work any longer and web service log generates an error which is here : "On Elapsed Time The request was aborted: Could not create SSL/TLS secure channel"

"The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel."

how can i solve this error ?

please help me .

great regards

Microsoft Technologies based on the .NET software framework.
3,323 questions
0 comments No comments
{count} votes

Accepted answer
  1. Jiale Xue - MSFT 28,626 Reputation points Microsoft Vendor

    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("");
                // Create a ServiceHost instance
                using (ServiceHost host = new ServiceHost(typeof(YourService), baseAddress))
                        // Enable metadata publishing
                        ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
                        smb.HttpsGetEnabled = true;
                        // 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
                        Console.WriteLine("The service is ready at {0}", baseAddress);
                        Console.WriteLine("Press <Enter> to stop the service.");
                        // Close the ServiceHost
                    catch (Exception ex)
                        Console.WriteLine("An error occurred: {0}", ex.Message);
        // Define your service contract and implementation
        public interface IYourService
            string YourMethod();
        public class YourService : IYourService
            public string YourMethod()
                return "Hello, World!";

    Replace "" 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,


    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.

0 additional answers

Sort by: Most helpful