Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

heroku+django+mysql: sslmode not supported. #107

Open
lwaite opened this issue Jul 18, 2018 · 16 comments
Open

heroku+django+mysql: sslmode not supported. #107

lwaite opened this issue Jul 18, 2018 · 16 comments
Labels
easy pickings a reasonably easy issue, something that might be good for a first-time contributor to work on feature this is a request for a new feature needs pr needs a pull request to move forward

Comments

@lwaite
Copy link

lwaite commented Jul 18, 2018

Based on docs: there's no 'sslmode' attribute. The following code gives me the exception: 'sslmode' is an invalid keyword argument.
This issue is possibly related to other backends like sqlite as well.

Workaround:
On settings.py after:
django_heroku.settings(locals())
add:
del DATABASES['default']['OPTIONS']['sslmode']

@marcpozzi
Copy link

Thank you very much !

@jacobian jacobian added easy pickings a reasonably easy issue, something that might be good for a first-time contributor to work on feature this is a request for a new feature needs pr needs a pull request to move forward labels Jul 24, 2019
@jacobian
Copy link
Collaborator

We should definitely support this without a workaround.

Is there a reason that sslmode shouldn't be the default?

@AminuIsrael
Copy link

I got this error:
del DATABASES['default']['OPTIONS']['sslmode']
KeyError: 'OPTIONS'

@nwthomas
Copy link

Same - I'm getting a KeyError whenever I try to do anything after using del DATABASES['default']['OPTIONS']['sslmode']

@AminuIsrael
Copy link

I got it fixed, don't add that code to the settings.py file, use your default database and you should be fine

@sheoak
Copy link

sheoak commented Mar 30, 2020

I got it fixed, don't add that code to the settings.py file, use your default database and you should be fine

what do you mean by "use your default database"?

zhaziragaripolla added a commit to zhaziragaripolla/StartDeutsch-django that referenced this issue Apr 1, 2020
@robomantis19
Copy link

thats funny. How when installing wooey I got the sslmode error, then when I added that line of code it fixed it, just to get the Options key error later when running ./manage.py addscript for wooey. Just delete and use the default database and back to normal workflow.

@AminuIsrael
Copy link

AminuIsrael commented May 1, 2020

To fix this error, just use

django_heroku.settings(locals())

At the end of the line, No need adding

del DATABASES['default']['OPTIONS']['sslmode']

@eshwetak
Copy link

eshwetak commented Dec 5, 2020

Thank you.

@juancresc
Copy link

not working for me

@FredericoLeao
Copy link

Based on docs: there's no 'sslmode' attribute. The following code gives me the exception: 'sslmode' is an invalid keyword argument. This issue is possibly related to other backends like sqlite as well.

Workaround: On settings.py after: django_heroku.settings(locals()) add: del DATABASES['default']['OPTIONS']['sslmode']

this worked for me, thanks

@palfrey
Copy link
Member

palfrey commented Dec 14, 2022

The problem appears to be more a matter of django_heroku hardcoding sslmode.

Fun question: how should we deal with this? Options include:

  1. Throw an error when setting for non-Postgres DB's as it's non-obvious how to support it (e.g. MySQL doesn't appear to have an equivalent arg)
  2. Throw a warning, which would let things like django_heroku continue to work while flagging it, but only set it for Postgres
  3. Figure out if we can support this for other DBs. Doesn't make sense at all for SQlite for example.
  4. Remove the option, and get Postgres folks to add sslmode=require to their URL

Thoughts anyone?

@palfrey
Copy link
Member

palfrey commented Dec 21, 2022

I'm leaning towards the option 4 ("Remove the option, and get Postgres folks to add sslmode=require to their URL") as that's used in test_database_url_with_options for example.

This would be a major version bump, but I'm thinking this plus the change from #114 (comment) in one go for that.

@ddelange
Copy link

fwiw it looks like 'OPTIONS': {'ssl': True} is needed for mysql instead of 'OPTIONS': {'sslmode': 'require'} for postgres ref https://stackoverflow.com/q/59894554

@ddelange
Copy link

maybe nothing needs to be specified for mysql? if at all, maybe sslMode=REQUIRED?

For 8.0.12 and earlier: As long as the server is correctly configured to use SSL, there is no need to configure anything on the Connector/J client to use encrypted connections (the exception is when Connector/J is connecting to very old server versions like 5.6.25 and earlier or 5.7.5 and earlier, in which case the client must set the connection property useSSL=true in order to use encrypted connections). The client can demand SSL to be used by setting the connection property requireSSL=true; the connection then fails if the server is not configured to use SSL. Without requireSSL=true, the connection just falls back to non-encrypted mode if the server is not configured to use SSL.

For 8.0.13 and later: As long as the server is correctly configured to use SSL, there is no need to configure anything on the Connector/J client to use encrypted connections. The client can demand SSL to be used by setting the connection property sslMode=REQUIRED, VERIFY_CA, or VERIFY_IDENTITY; the connection then fails if the server is not configured to use SSL. With sslMode=PREFERRED, the connection just falls back to non-encrypted mode if the server is not configured to use SSL. For X-Protocol connections, the connection property xdevapi.ssl-mode specifies the SSL Mode setting, just like sslMode does for MySQL-protocol connections (except that PREFERRED is not supported by X Protocol); if not explicitly set, xdevapi.ssl-mode takes up the value of sslMode ( if xdevapi.ssl-mode is not set and sslMode is set to PREFERRED, xdevapi.ssl-mode is set to REQUIRED).

https://dev.mysql.com/doc/connector-j/8.0/en/connector-j-reference-using-ssl.html

@palfrey
Copy link
Member

palfrey commented Feb 16, 2023

Any thoughts on this @mattseymour ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
easy pickings a reasonably easy issue, something that might be good for a first-time contributor to work on feature this is a request for a new feature needs pr needs a pull request to move forward
Projects
None yet
Development

No branches or pull requests