-1

I am trying to write code in JavaScript that will allow me to send an HTTPS command to an IP phone.

I have code that works for HTTP:

url = "http://123.456.789.101/cgi-bin/api-send_key";

if (url != "") {
    var params = "passcode=admin&keys=" + withcolon + "SEND";
    var http = new XMLHttpRequest();

    http.open("GET", url + "?" + params, true);
    http.onreadystatechange = function () {
        if (http.readyState == 4 && http.status == 200) {
            alert(http.responseText);
        }
    }
    http.send(null);
}

Again, this code works. However, I'd like to send it out via an HTTPS message. What changes can be made to accomplish this?

Nisse Engström
  • 4,738
  • 23
  • 27
  • 42
John Casey
  • 15
  • 7
  • Is your server using https? – nadavvadan Sep 12 '17 at 21:32
  • No. It is an HTTP server. The I am trying to dial the IP phone from Outlook, which is HTTPS. I can set the phone to HTTPS, then send a message to the phone from the browser using HTTPS, but I cannot dial out from outlook. – John Casey Sep 12 '17 at 21:34

1 Answers1

0

url = "https://123.456.789.101/cgi-bin/api-send_key";

With that being said, it's now going to check the certificate. Certificates aren't usually issued to an ip address. You would have to make sure that the browser accepts that, most likely self-signed, certificate.

pucky124
  • 1,489
  • 12
  • 24
  • I have tried this. If I send https://111.16.2.154/cgi-bin/api-send_key?passcode=admin&keys=1:2:3:4:8:1:1:7:9:0:0:SEND in the browser, it works. However, if I try to send it using the code, it will not dial. – John Casey Sep 12 '17 at 23:33
  • Is the page running the script loaded with https as well? What errors are you getting? This page might have some relevent info as well https://stackoverflow.com/questions/11690191/cross-domain-request-from-http-to-https-aborts-immediately – pucky124 Sep 13 '17 at 00:45
  • If I attempt to send the message using HTTPS, I do get a message from the browser (Chrome and Edge), telling me that the site is not secure. I have to choose to proceed anyway. If I try to execute the message using code, I don't get any error or message. It just doesn't do anything. – John Casey Sep 13 '17 at 15:08
  • Did you follow the steps to add the certificate from the link I posted? Since you are trying to access an insecure site via javascript there is no mechanism to manually override like there is when typing into the address bar. If you manually add the certificate it should work as you wrote it. – pucky124 Sep 13 '17 at 18:26
  • Am I adding the certificate to outlook or to the IP phone ? – John Casey Sep 13 '17 at 19:10
  • Outlook, or whatever is running the js code. It may be worth doing a little research on what https is and how it works. – pucky124 Sep 13 '17 at 20:42
  • Dynamics 365 is running the code. I can dial from a customer entry on the CRM website. I'm trying to dial out from the Dynamics 365 for Outlook client. You are right though, I need to do more research. – John Casey Sep 13 '17 at 20:52