5

I'm trying to get the NET::ERR_CERT_DATE_INVALID error fixed for local development.

I'm working with a xampp setup (PHP 7.4, Windows 10). After trying several tutorials on self signed certificates, I'm now on a point where I'm stucked.

What I've done so far

  • Creating a self signed certificate, using openssl in xampp like this:

    set OPENSSL_CONF=C:\xampp\php\extras\openssl\openssl.cnf

    openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout server.key -out server.crt

I successfully created the server.crt and server.key files and put them in the correct directory C:\xampp\apache\conf\[ssl.crt]/[ssl.key]

I've also tried to download the cacert.pem bundles from CA certificates and uncomment the necessary lines in my php.ini file.

I've always restarted my server afterwards, but none of the above methods are working.

toffler
  • 1,231
  • 10
  • 27
  • 1
    https://stackoverflow.com/questions/35531347/localhost-blocked-on-chrome-with-privacy-error this might help? – n212 Jul 20 '21 at 09:19
  • 1
    @n212 thanks, I've read this article yesterday... it's kind of a workaround but I think not the correct solution, however if nothing else works - this shoud do it :) – toffler Jul 20 '21 at 09:57
  • 1
    Did you checked the dates in your host and in xampp there are correct? – adampweb Jul 20 '21 at 13:38
  • 1
    @AdamP. the dates are correct but my certificate is expired, that's why I'm trying to create a new one. – toffler Jul 21 '21 at 08:14
  • 2
    The tutorial that you linked is made for VMWare (a virtualization software similar to VirtualBox). Look for this tutorial instead of what you used: https://shellcreeper.com/how-to-create-valid-ssl-in-localhost-for-xampp/ – adampweb Jul 23 '21 at 16:27
  • @AdamP. I've created a new certificate using that tutorial. It basically works, but I'm getting a new error: `NET::ERR_CERT_COMMON_NAME_INVALID` . It shouldn't happen because I've completed all the steps – toffler Jul 26 '21 at 08:04

1 Answers1

3

First, open the certificate from the browser and see if the browser presents you the newly applied certificate. If it is the old one, you can try following procedures.

  1. Go and have a look at inside of the Apache configuration file whether you've replaced the correct certificate files. Maybe your virtual host of the domain is not using the .crt file you're replaced.

  2. Open the incognito mode of the browser and open the website. Sometimes the certificates get cached. In case it's the caching of the browser, clear the cache and try again.

Chandana
  • 199
  • 7
  • The Browser finally uses the generated certificate, thanks for the tip with the cache. I might accept that answer, since it solves the origin problem. Howewer, I now get a `NET::ERR_CERT_COMMON_NAME_INVALID` error on my certificate. – toffler Jul 26 '21 at 08:02
  • 1
    This happens when the certificate installed domain name differs from the URL you are accessing. Open and view the certificate to see the "Issued to" domain name. That will give you a clue what to do. – Chandana Jul 27 '21 at 10:29