jkhamler
jkhamler

Reputation: 593

Symfony4/Doctrine - Cannot connect via SSL (DBAL Config)

Can somebody please let me know what's missing? All %env% variables are correct. Everything worked perfectly until I enabled SSL.

Using these connection details and 'Key.crt.pem' I have no issues connecting to the database using Sequel Pro.

Error:

{"code":500,"message":"An exception occurred in driver: SQLSTATE[HY000] [9002] SSL connection is required. Please specify SSL options and retry."}

doctrine:
dbal:
    # configure these for your database server
    driver: 'pdo_mysql'
    server_version: '5.7'
    charset: latin1
    default_table_options:
        charset: latin1
        collate: latin1_swedish_ci
    dbname:               '%env(resolve:DATABASE_NAME)%'
    host:                 '%env(resolve:DATABASE_HOST)%'
    port:                 '%env(resolve:DATABASE_PORT)%'
    user:                 '%env(resolve:DATABASE_USER)%@%env(resolve:DATABASE_HOST)%'
    password:             '%env(resolve:DATABASE_PASSWORD)%'
    mapping_types:
            enum: string
    options:
        MYSQL_ATTR_SSL_CA : '/Path/Key.crt.pem'

Upvotes: 2

Views: 1707

Answers (2)

GregOs
GregOs

Reputation: 413

To answer @sanjok Gurung

From symfony 3.2, you can use php constants in yaml files. In this example, it would give:

options:
   !php/const:PDO::MYSQL_ATTR_SSL_CA: : '/Path/Key.crt.pem'"

Ref: https://symfony.com/blog/new-in-symfony-3-2-php-constants-in-yaml-files

Upvotes: 3

jkhamler
jkhamler

Reputation: 593

I've sorted it.

!php/const:PDO::MYSQL_ATTR_SSL_CA:

Upvotes: 1

Related Questions