0

My error is The request was aborted: Could not create SSL/TLS secure channel. I am using the example code from the Avaya office management api documentation. I can't get CertificateValidationCallback to compile.

protected void Page_Load(object sender, EventArgs e) {

    ServicePointManager.ServerCertificateValidationCallback = new
    System.Net.Security.RemoteCertificateValidationCallback(CertificateValidationCallback); 
    String username = "";
    String password = "";
    String url = "https://10.207.251.41:7070/WebManagement/ws/sdk/security/authenticate";
    CookieContainer cookieContainer = new CookieContainer();
    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
    request.Credentials = CredentialCache.DefaultCredentials;
    request.Method = "GET";
    request.ContentType = "application/json";
    request.Headers.Add("X-User-Client", "Avaya-WebAdmin");
    request.Headers.Add("X-User-Agent", "Avaya-SDKUser");
    String credentials = Convert.ToBase64String(ASCIIEncoding.ASCII.GetBytes(username + ":" + password));
    request.Headers.Add("Authorization", "Basic " + credentials);
    request.CookieContainer = cookieContainer;

    HttpWebResponse response = (HttpWebResponse)request.GetResponse();
    var resStream = response.GetResponseStream();
    var reader = new StreamReader(resStream);
    String responseContent = reader.ReadToEnd();

    response.Close();


}
qpc4ever
  • 67
  • 6
  • Sounds like the certificate is fake/self-signed. There's a magic variable you can set that ignores certificate errors, but folks will scowl if I share that non-production-quality information :P – Davesoft Jun 05 '19 at 14:49
  • get your callback working; see https://stackoverflow.com/a/5043083 – user326608 Jun 05 '19 at 15:00

1 Answers1

1

If the certificate is not trusted by Certification Authority (and I don't think so because of the request, but it sounds instead like a test certificate), you shall install it on your system as trusted by MMC console, adding "certificate" snap/in, selecting your local pc as destination. Then, in the snap in shall appear a list of certificate folders, find the "trusted root certificates" and import the certificate (if you don't have it, I think that you can download it with the browser visiting the link https://10.207.255.45:7070 ). Once it's installed there, this could fix your problem

Sycraw
  • 543
  • 3
  • 17