2

I have an application that can be downloaded from my website and run on user PC. This application doesn't do anything special and just allows the web page to access the scanner. It uses SignalR for communication. Basically, I run SignalR server under WinForms application and have javascript client that tries to access it through http://localhost:8084/signalR. Everything works fine when I use HTTP version of the web application, but fails, when I use HTTPS for my web application: Most of the browsers don't allow unsecured connections from a secure page. So, I've created a self-signed certificate that is installed on user system during installation and it works fine for Chrome, IE and Opera, but fails for Firefox and Edge. So I was thinking, is there a better way to access SignalR applications that are running on localhost from webpage under https?

Smooyk
  • 389
  • 4
  • 20
  • Did you try the accepted answer way? what was the outcome? and also how you add ssl to setup file installed on user computer? – Hadee Jan 31 '18 at 03:32
  • @Hadee Yes, I did. It works well with some minor changes for Edge and FF. SSL cert was embedded into installer – Smooyk Feb 01 '18 at 07:45
  • could you tell me how to added SSL cert to your installer? Is there any problem with computer name on cert? – Hadee Feb 01 '18 at 22:09
  • @Hadee You can embed any file just be settings its Build Action to Embedded Resource in Visual Studio. Computer name for cert is localhost, if you install this cert as trusted there will be no problems. – Smooyk Feb 05 '18 at 13:59

1 Answers1

2

There isn't a better way. You are correct in your understanding that "[m]ost of the browsers don't allow unsecured connections from a secure page". I believe there isn't a browser that will allow this. Therefore if you want to call out from a secured website, you must use a secured connection as well.

I don't know the issue you're experiencing with Edge, as I can confirm that it does work. Firefox will NOT trust a certificate in the cert store, even if it is a trusted root or has a trusted root certificate. You have to manually add an exception for this certificate. Details, or at least information that will let you find the correct method to do this, can be found here.

There are some things you have to do in order to make sure your certificate and configuration is correct. First, you have to have a well formed certificate with a public and private key and a well formed certificate authority cert with only its public key. By "well formed" I mean it must contain all information required by browsers for full trust, such as a Subject Alternative Name entry.

You can use OpenSSL to generate the CA, then use that to sign a certificate you will use for the SSL port. Export the CA's public key and the SSL certificate's public and private keys. Exporting the CA's private key is a MAJOR no no. That would allow third parties to create new certs from it and install them on your client's machine. The CA gets installed in the machine's Trusted Root Certification Authorities store. The SSL cert can go into the Personal/Certificates store.

Once you have these, you have to configure the URL/Port you will use for access and SSL using the netsh command line tool. Add a URLACL to allow the application to access the url and port (netsh.exe http add urlacl), and then assign the certificate to the port (netsh.exe http add sslcert ).

Having done all this, you should be good to go. The only real problems you should have are Chrome being very demanding about the configuration of your certificates and Firefox refusing to trust your CA certificate even though it is in your trusted certificate store. Bastard.

And for Edge, I can definitely guarantee if you do all the above it will work. If it doesn't, you need to consult the js console to see what errors it is throwing.