dtamab
dtamab

Reputation: 85

SSL Yii connection to postgresql Google cloud database

I’m newbie user of Yii and I need to connect my Yii2 application to a Google cloud database (postgres). I need to made the connection using the SSL certificates I already have. I have all the credentials (host, user, 3x ssl, etc).

The thing is I’m able to connect to this remote google database using both PgAdmin client and the Google SDK console (Google Shell), but I can’t connect my Yii2 application to this database. I read a lot of documentation and found nothing.

psql "sslmode=verify-ca sslrootcert=path/to/my/server-ca.pem sslcert=path/to/my/client-cert.pem sslkey=path/to/my/client-key.pem hostaddr=google-instance-host user=david.tamarit dbname=google-db-name"`

Then, I put my password and I'm connected to my database in Google shell.

How can I connect to my google cloud database using Yii?

Thanks in advance!

Upvotes: 0

Views: 1289

Answers (1)

Bizley
Bizley

Reputation: 18021

Since the DB is not on your machine there is no need for you to have PostgreSQL installed and this is the reason (I think) that these constants are not recognised. Try this:

'attributes' => [
    'sslmode' => 'verify-ca',
    'sslkey' => 'path/to/my/client-key.pem',
    'sslcert' => 'path/to/my/client-cert.pem',
    'sslrootcert' => 'path/to/my/server-ca.pem',
],

Upvotes: 2

Related Questions