prisma: `npx prisma` results in self-signed cert error, though npm config cafile is properly set
Bug description
When I run npx prisma migrate
, I get the following error:
Error: request to https://binaries.prisma.sh/all_commits/73e60b76d394f8d37d8ebd1f8918c79029f0db86/windows/prisma-fmt.exe.gz.sha256 failed, reason: self signed certificate in certificate chain
Because my corporate proxy re-signs TLS traffic. I have npm configured to accept a cafile that describes the self-signed cert, which allows npm install
to proceed w/o issue. However, the npx prisma migrate
fails … presumably because prisma itself is trying to make an https request and is unaware of the npm cafile setting?
I believe we need a way make prisma aware of the cafile.
How to reproduce
- Open a terminal on a computer that is on a network behind a proxy that re-signs TLS traffic
- Execute the command “npx prisma migrate”
That should result in the error I’m seeing.
Expected behavior
I expect npx prisma migrate
to run w/o error. 😃
Prisma information
N/A
Environment & setup
- OS: Windows 10
- Database: PostgreSQL
- Node.js version: v14.18.1
Prisma Version
Ironically, npx prisma -v
results in the same error. However, inspecting my node_modules
, I see that it is:
3.9.2
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 3
- Comments: 19 (7 by maintainers)
Actually, one of my teammates pointed out that if I set the environment variable
NODE_EXTRA_CA_CERTS
to the path to my.pem
file, thennpx prisma migrate
works as intended.Run this before: set NODE_TLS_REJECT_UNAUTHORIZED=0
I can confirm that setting
NODE_EXTRA_CA_CERTS
worked for me as well. No need to download the library/engines and reference them locally.That also solved my
schemaPush
error mentioned above, presumably because of utilizing the wrong engine as you mentioned @janpio. As that is no longer an issue, I’m not going to worry about opening up a new ticket as it was likely operator error (i.e. downloading the wrong engine versions).For reference, running
npx primsa -v
produced the following:Looks like the commit SHAs for all of those are
34df67547cf5598f5a6cd3eb45f14ee70c3fb86f
, whereas the ones I had been downloading were7d77a7cd570c9dedb4cdf31a1cbec615cf2e1eda
. The reason I did this was because there wasn’t a corresponding34df67547cf5598f5a6cd3eb45f14ee70c3fb86f
commit/download for the query library, and I assumed the library and engines would benefit from being from the same commit. I guess a bad assumption. If a user is forced into downloading and referencing the query library and other engines locally, some documentation on how to choose the “right” versions could be useful.Anyways – thanks @eric79 for opening the thread and providing a solution! (and thanks @janpio for the feedback as well!)
Having this same issue. Came across this other ticket where someone was having an issue with a self-signed cert in the chain.
From @janpio’s comment on that thread, it appears that the engines can be downloaded manually and then paths to those engines can be set via env vars (some documentation is here about it as well).
But unfortunately, after downloading the 4x engines and 1x library, I’m still hitting a snag, but I think it has to do with me not using Docker correctly (that’s where our prisma scripts are actually run).
Here are the engines/libraries that I’ve downloaded specifically, if that helps:
I’ll update once I get my Docker stuff figured out to say whether or not downloading/using these binaries as suggested worked or not.
I set the npm cafile like so:
I haven’t personally used a tool to re-sign TLS traffic, but these look promising: https://www.netresec.com/?page=PolarProxy https://geekflare.com/ssl-test-certificate/
@vitjaz , this
.pem
file would be specific to your organization and their local certificate authority that issues certificates used to resign TLS traffic as it crosses the boundary to your organization through the proxy. Perhaps someone else at your organization would know where to find that.pem
file?I turned this into two issues on our side as well:
I believe this is the normal behavior and prisma is working properly. It just wasn’t an obvious step for those of us who are not experts in running applications in the node ecosystem. Maybe it will just be good that this issue is out there so future users having similar issues can find it.
I will close the issue.