I have made a website in angular for connecting with the local server which is basically a black box. The black box is connected to the same router as that of my laptop and I am accessing the server via. IP address it generates on the browser. On the server, I have installed a self-signed certificate. On windows, SSL works on the browser showing the "Your connection is not private" warning, there we can go to advanced and proceed to the website. But on macOS (Big Sur v11.5.1), there is no such option available. How can we resolve this problem via. code and not the browser settings.
CodePudding user response:
localhost does not support https. However, you can use tools like NGrok
for it. I would advise you to read this: https://ngrok.com/docs
CodePudding user response:
You cannot solve this problem purely via code. The SSL verification works like this:
- The browser encounters an SSL certificate
- It'll look up the issuer of the certificate (and possibly the issuer of the issuers certificate as well and so an, thus traversing the "certificate chain")
- Once it has reached the root of the certificate chain (the primordial certificate without issuer), it looks this root certificate up in an own database "inside" the browser. If, and only if, the top issuer certificate is contained in the database, the browser considers this connection to be safe.
(This is just a very basic and simplified overview! I'd suggest you to dig deeper into SSL/TLS certificate chaining etc.)
The problem is, for your self-signed certificate, there is no issuer (that's why it is called "self-signed".)
What you could try:
- Create your own certification authority ("CA"; there are many tutorials on the internet) and thus such a "root" certificate.
- Use this CA to create and sign a certificate for your server.
- Import the root CA certificate in your browser/operating system, thus adding in to the database of trusted certificates.
This is quite a bit of work, but the "cleanest" way to deal with your problem.
Alternatives:
- Don't use HTTPS locally, just plain HTTP.
- Get an "official" certificate from a trusted CA. These are normally quite expensive and I don't think they would issue the for a local-only server.