mirror of
https://github.com/FiloSottile/mkcert.git
synced 2026-04-25 05:26:03 +03:00
[GH-ISSUE #331] Chrome ERR_CERT_VALIDITY_TOO_LONG error #214
Labels
No labels
TLS stack issue
Windows
bug
duplicate
duplicate
enhancement
help wanted
help wanted
pull-request
question
question
root store
waiting for info
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/mkcert#214
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @franz-josef-kaiser on GitHub (Jan 13, 2021).
Original GitHub issue: https://github.com/FiloSottile/mkcert/issues/331
Chrome refuses to access the resource with
NET::ERR_CERT_VALIDITY_TOO_LONG.I can add an exception by using
--unsafely-treat-insecure-origin-as-secureand clicking the "Advanced" > "Proceed to ." button on the warning page. Chrome still will show "Not secure" in the address bar.It would be nice to have this working 100%, not just 90% :)
The cert I just generated has a validity range of exactly 10 years:
Not valid before: Wednesday, 13. January 2021 at 12:45:06 Central European Standard Time
Not valid after: Monday, 13. January 2031 at 12:45:06 Central European Standard Time
Note: Chrome displays not only the cert, but also the rootCA in their error page.
Below you can find an example I just generated (the second cert is the
rootCA.pemfile contents):Note: I have no idea if this is a bug/ regression where I can't find a way to debug and find it's root cause, or Chrome just updated in the background and this is expected default behavior.The fingerprints are correct and matching. Here're the scripts to check.
Setup
The whole test/ demo setup contains out of Alpine Linux containers. The containers are orchestrated using Docker Compose. All public facing containers share the same network and a named volume:
Process:
docker-compose up devcertsand then creates the certs. It saves it to the named volume, which then shared.cp ./root* "$(mkcert -CAROOT)"cd ./path/to/certs; mkcert -install.Provider: Docker Compose/ Docker using The mkcert image by kklepper.
System
mkcert:Host OS: MacOS 11.1 Big Sur
Google Chrome: Version 87.0.4280.141 (Official Build) (x86_64)
Firefox: 84.0.2 (64-bit)
Safari: Version 14.0.2 (16610.3.7.1.9)
Might be related to:
Note: Verbose process description, keywords, etc. are meant to offer better indexing to help others find this issue and hopefully also find some help.
@franz-josef-kaiser commented on GitHub (Jan 22, 2021):
As it turns out, Google limits cert validity to 398 (397) days, effective with 2020-09-01. Announcement in full length here. This results in
mkcertbeing effectively broken for Chrome/ Chromium right now.Pointer to the
cert.goline here/ 1.4.3.397 (considering leap seconds w/ 86,400 sec/d) days equals 1 year, month, 1 day. The following change is needed and assumes that every month has 31 days (to be on the safe side).
@franz-josef-kaiser commented on GitHub (Jan 22, 2021):
@FiloSottile Could you please take a look at the issue and the provided PR? Thanks in advance!
@FiloSottile commented on GitHub (Jan 22, 2021):
That Chrome restriction only applies to publicly trusted certificates. There is macOS-level restriction which we have been first working around and then complying with for a long time. Judging from your NotBefore and NotAfter, you are using a very old version of mkcert. Please update and check if the issue persists.
@franz-josef-kaiser commented on GitHub (Jan 22, 2021):
The version is correct and
v1.4.3as reported above. But you have been right regarding the date. I double and tribble checked and noticed at some point that even if I wipe clean everything, theNotBeforedate stayed the same old date for every newly generatedrootCA.pem. At around 10 repetitions including several restarts, I decided to generate everything new, but to not clean the system store via the keyChain app. And all of a sudden I had two certs and one of them had the current date set asNotBeforedate. I couldn't find any clue if there's some cache or hidden store somewhere. Searching the whole drive for somerootCA.pemreturned zero matches. No idea what's the reason behind this (OS etc as reported in the initial comment). Any clues appreciated as I'd really like to understand what's going on here. Thanks in advance.@FiloSottile commented on GitHub (Jan 22, 2021):
I really don't see how mkcert v1.4.3 could have generated that certificate. Are you sure you're not using a different version of mkcert inside a container or something like that?
@franz-josef-kaiser commented on GitHub (Jan 25, 2021):
@filippobuletto yes, I am sure about that. But please don't get me wrong here: I assume that this does not happen because of mkcert.
Below you can find a cert that I generated yesterday on 2021/01/25. The expiration and not valid before dates are set to 2021/01/22, which is 3 days before the date I generated the cert.
@amrik-samra-kr commented on GitHub (Apr 19, 2021):
I did a fresh re-install mkcert and I'm on version 1.4.3. The expiry date of the cert is March 08, 2031. I think they fix does not work in the latest version.
@cnd4 commented on GitHub (Jun 29, 2021):
I hope to not up a stale issue when not necessary but FYI,
kklepper/mkcert_aDocker image downloadsmkcert1.3.0(you can rundocker pull kklepper/mkcert_a:alpine && docker inspect kklepper/mkcert_a:alpineand see theCmdpart to check this, I would add this is not a best practice to download the binary at container startup instead of integrating the binary inside the image).I recommend you to use flesch/mkcert which has a
1.4.3tag or unsanctioned/mkcert with thev1.4.3tag.Both are recent images so I don't know if maintainers will provide updates in the future but at least, they provide for now the latest
mkcertversion.EDIT: I see you installed latest
mkcertlocally, so you don't need to use the Docker image. Or maybe I don't understand what you did, in that case I would be happy to have more details to understand the bug you got.@cemiboii commented on GitHub (Jul 19, 2021):
Trying to use flesch/mkcert for my certificate. I want to combine it with my flask application which is also running in a docker container. After building both my flask app over localhost and mkcert I want to access them via my local macOS machine.
As I am pretty new to docker i am trying to use two Dockerfiles and combine them in a docker-compose.yml
Unfortunately when the cert is being generated i get the message:
Also Chrome is giving me the NET::ERR_CERT_AUTHORITY_INVALID - error. For me it is clear, that my CA is not valid but I have no idea what else I have to do.
Any ideas from your side?
@cnd4 commented on GitHub (Jul 20, 2021):
@cemiboii if you generate certificates in the container, Chrome (and any other browser) won't "know" the certificate.
As you certainly know,
mkcertgenerate a certificate authorithy (CA) which in turns is used to sign domains certificates. Your browser just need to know the certificate authority.When using
mkcerton the host (not on a container), it can install the root CA in your system and browsers automatically. But if you usemkcerton the container,mkcertwill try to install the root CA in… The container. Your browsers are not in the container.But don't worry, there is a workaround! You'll just need to install the root CA manually.
You need to create
volumesin yourmkcertservice in your Compose file and set aCAROOTenvironment variable for this service to use the volume as the certificates output.mkcert --helpgive you little information aboutCAROOTenvironment variable.Then you'll need to manually import the root CA in your browser(s) because, as I said,
mkcertcan't do it automatically from the container (I recommend you to set aTRUST_STORESvariablew to an empty string somkcertwon't even try to install certificates in the container, it's not required). If you don't know how to import a certificate authority in Chrome, you can find easily by searching "chrome import root ca" (here is an example documentation).I hope those information help you.
Tip about Docker: do not use
:latestimages but use a specific version, so you update manually when required. It prevents you from receiving unwanted updates (which can break the API).Another tip: using volumes with Docker on macOS can be really slow. For certificates, you won't care because it's not read/write intensive but don't be surprised if you use volume for more disk intensive container.
@cemiboii commented on GitHub (Jul 20, 2021):
@sambonbonne thanks a lot for your detailed answer.
In the meantime I was trying a new approach with this solution #169 and I would say that it is working.. at least for now.
I also have a volume and am able to access both rootCA.pem and rootCA-key.pem and set
TRUST_STORESto an empty string.My container output is now the following:
Even though everything looks good, after importing my rootCA in my macOS keychain I still get the NET::ERR_CERT_AUTHORITY_INVALID error. When I am checking the information of my rootCA cert and compare it with the certificate of my localhost they differ. Maybe I am doing it wrong or im just a big nooby in this case.
@cemiboii commented on GitHub (Jul 21, 2021):
Okay I think I just found out, why I still got the certificate error.
Just installed mkcert on my local machine, set CAROOT to my shared folder / volume where my rootCA is located and did a mkcert -install on my local machine. Now it's working properly as it should.
I think that's it. Thanks again for helping me out on this one.
@casedup commented on GitHub (Jul 10, 2023):
What if mkcert was installed inside a WSL container.. how do we get the CA into the browser from there?