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();


}
2
  • 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 5, 2019 at 14:49
  • get your callback working; see stackoverflow.com/a/5043083
    – user326608
    Jun 5, 2019 at 15:00

1 Answer 1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.