laravel-google-cloud-storage icon indicating copy to clipboard operation
laravel-google-cloud-storage copied to clipboard

Fix key_file config

Open Gilg4mesh opened this issue 5 years ago • 6 comments

Gilg4mesh avatar Aug 21 '19 18:08 Gilg4mesh

Actually it might be a bug of laravel, a GOOGLE_CLOUD_PRIVATE_KEY is having many line break chars in a single string, the private key works when hard-coded in config file, but when reading private key from .env file, laravel replaced the '\n' to '\\n', and ended at 'openssl_sign(): supplied key param cannot be coerced into a private key' when uploading files.

Gilg4mesh avatar Aug 22 '19 19:08 Gilg4mesh

+1 ! We hit this exact same bug(?) and your PR fixes it for us. Thanks!!!

There is indeed an issue here, not sure why an issue was never created.

@nicja Are you saying that you successfully authenticated without a json file and setting the various key_file environment variables?

My GOOGLE_CLOUD_PRIVATE_KEY is set to something like this:

-----BEGIN PRIVATE KEY-----\nprivatekeyprivatekeyprivatekeyprivatekeyprivatekeyprivatekeyprivatekeyprivatekeyprivatekeyprivatekeyprivatekeyprivatekeyprivatekeyprivatekeyprivatekeyprivatekeyprivatekeyprivatekeyprivatekeyprivatekeyprivatekeyprivatekeyprivatekeyprivatekeyprivatekeyprivatekeyprivatekeyprivatekeyprivatekeyprivatekey\n-----END PRIVATE KEY-----\n

there are newlines characters in there. i'm curious how you got this to work without OP's PR

RafiGreenberg avatar Dec 11 '19 00:12 RafiGreenberg

first google app engine do not support .env file to you are expected to move all your environment variable to a file called app.yaml eg:

runtime: php72

env_variables:

Put production environment variables here.

APP_KEY: YOUR_APP_KEY APP_STORAGE: /tmp VIEW_COMPILED_PATH: /tmp SESSION_DRIVER: cookie

bere6255 avatar Dec 11 '19 00:12 bere6255

first google app engine do not support .env file to you are expected to move all your environment variable to a file called app.yaml eg:

runtime: php72

env_variables:

Put production environment variables here.

APP_KEY: YOUR_APP_KEY APP_STORAGE: /tmp VIEW_COMPILED_PATH: /tmp SESSION_DRIVER: cookie

I am not using google app engine. Your comment does not apply to this PR or to the issue in question.

RafiGreenberg avatar Dec 11 '19 16:12 RafiGreenberg

Cool! Works with updating this PR. Thanks.

Vendin avatar Dec 11 '19 20:12 Vendin

It worked. Thank you a lot.

felipemeddeiros avatar May 25 '20 20:05 felipemeddeiros