title: Could not create SSL/TLS secure channel. SecureChannelFailure
body: <p>I'm getting an SSL error when making a SOAP call with an SSL certificate: </p>
  
  <blockquote>
    <p>The request was aborted: Could not create SSL/TLS secure channel.</p>
  </blockquote>
  
  <p>The weird thing is that if I load the certificate in Firefox and visit the endpoint or make a call to the API without sending any data, I don't get any error message and it connects successfully. The company exposing the API has also mentioned that the certificate is kosher.</p>
  
  <p>The certificate I'm loading has full privileges to "Everyone". I've tried every solution I've seen on the internet but still getting the error.</p>
  
  <p>Here is my code that creates the request:</p>
  
  <pre><code> ServicePointManager.Expect100Continue = true;
   ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
   var request = (HttpWebRequest)WebRequest.Create(plugin.EndPoint);
   request.ContentType = "text/xml; charset=utf-8";
   request.Method = "POST";
  </code></pre>
  
  <p>The code to get the certificate (I've also tried with a pfx):</p>
  
  <pre><code>var cert = new 
   509Certificate2(@"C:\clientcert.p12", "FakePassword");
  request.ClientCertificates.Add(cert);
  </code></pre>
  
  <p>and the code for the request:  </p>
  
  <pre><code>  byte[] byteArray = Encoding.UTF8.GetBytes(xml);
      request.ContentLength = byteArray.Length;
      using (var dataStream = request.GetRequestStream())
                  {
                      dataStream.Write(byteArray, 0, byteArray.Length);
                      dataStream.Close();
  
  
                      using (WebResponse response = request.GetResponse())
                      {
                          using (var responseStream = response.GetResponseStream())
                          {
                              StreamReader reader = 
  new StreamReader(responseStream ?? throw new InvalidOperationException());
                              return reader.ReadToEnd();
                          }
                      }
  
                  }
  </code></pre>
  
  <p>Edit:</p>
  
  <p>Here is the trace output from running the request:</p>
  
  <blockquote>
    <p>System.Net Information: 0 : [11844]
    InitializeSecurityContext(In-Buffers count=2, Out-Buffer length=0,
    returned code=CertUnknown). System.Net Error: 0 : [11844] Exception in
    HttpWebRequest#63832831:: - The request was aborted: Could not create
    SSL/TLS secure channel.. System.Net Error: 0 : [11844] Exception in
    HttpWebRequest#63832831::EndGetRequestStream - The request was
    aborted: Could not create SSL/TLS secure channel..</p>
  </blockquote>
  
  <p>I also changed the SecurityProtocol:</p>
  
  <pre><code>ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12; 
  </code></pre>
  
  <p>Second Edit: I can get it to work in SoapUI but not in the .NET application by just loading the SSL certificate from the file system in SOAP UI.</p>