How do I securely store my p12 file in rails? My production web app will be in Heroku. The file is used to sign some documents dynamically.
Asked
Active
Viewed 1,126 times
1 Answers
5
Storing the p12 contents in an environment variable should be sufficiently secure on Heroku. This way it's at least not available in your code base or through your database.
You can setup Heroku environment variables like this:
heroku config:add P12_CONTENTS="$(cat /path/to/file.p12)"

Lee Ourand
- 91
- 1
- 2
-
And just in case anybody wonders; one can apparently at the very least safely store 128k in an environment variable: https://stackoverflow.com/questions/1078031/what-is-the-maximum-size-of-an-environment-variable-value . My P12 file for the Google APIs is 1.7k, so well below the limit. – Maik Hoepfel Oct 07 '14 at 13:56
-
1How do you add a file to Heroku like this if you're not checking the file into Git? (e.g. it's an open source project) – Kelsey Hannan May 19 '15 at 22:36
-
I get Error: invalid byte sequence in UTF-8 (ArgumentError) – tdc Aug 07 '15 at 19:56
-
If you're having trouble storing it, try converting like mentioned here: https://stackoverflow.com/a/63840143/823796 – kingliam Sep 11 '20 at 02:47