Provide access keys used for a SSL connection
See original GitHub issueI would like to use a ssl protected db with my application, which is deployed on Zeit Now. I am not sure how to get my p12 and my .pem file into the serverless function though.
I fount this issue: https://github.com/zeit/now/issues/749 , but I think it’s not possible that way, since we can’t combine env vars
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:11 (5 by maintainers)
Top Results From Across the Web
How an SSL connection is established - IBM
An SSL connection is established though a handshake (a series of communications exchanges) between the client and the server.
Read more >Private And Public Keys - SSL.com
The SSL/TLS protocol uses a pair of keys – one private, one public – to authenticate, secure and manage secure connections. These keys...
Read more >What you need to know about Private Key in SSL and Code ...
Your private key is the single most important component of your SSL certificate. It's what gives you the power to authenticate your website...
Read more >What is an RSA key used for? - SSL Certificates - Namecheap
RSA key is a private key based on RSA algorithm. Private Key is used for authentication and a symmetric key exchange during establishment...
Read more >SSL and SSL Certificates Explained For Beginners
Secure Sockets Layer (SSL) and Transport Layer security (TLS ) are protocols that provide secure communications over a computer network or ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Just posting here to bump this back up the priority level.
This was quite a pain to hack around and will be a problem for almost anyone needing to use Prisma in production with a serverless environment.
I am using CloudSQL with SSL from Google Cloud for my database and Vercel (like OP) for my deployment provider. This is how I hacked around it for now:
I store both the
server-ca.pemandclient-identity.p12in ENV variables (this gets tricky with the .p12 file and requires some base64 encoding) and then before the Prisma client is initialised I write them to the/tmpfolder which is available to vercel deployments:Then my database url for production looks like :
NOTE: Once you have encoded the
client-identity.p12into base64 it will exceed the size limit for ENVs in Vercel so you need to follow the guide mentioned here to encrypt it and then decrypt it before writing the file to disk.For completeness here is my
context.jswhere I initialise the Prisma client:Composing your .env is doable now. We didn’t implement it in the schema, but instead support .env template expansion: https://www.prisma.io/docs/concepts/components/prisma-schema#accessing-environment-variables-from-the-schema
So in your
.envfile:Then in production you can load a different .env or do it programmatically as @pantharshit00 suggested.
For the other part of the issue of accepting a certificate’s content as an environment variable. We probably won’t support this workflow directly, but recommend using the workaround @danhollick suggested. The main reason is that it’s easy enough to create a library in userland for handling this and environment variables have size limits.
If we get burned by
/tmpnot being writable in some serverless environment or enough people want this feature, we may revisit.Closing, but happy to re-open if this workflow doesn’t work for you. Thanks!