소스 검색

Allow SSL connections to a remote database server (#3742)

* Allow SSL connections to a remote database server

Add the following options in site_config.json to use ssl

- "db_ssl_ca" = "/path/to/ca/cert.pem"
- "db_ssl_cert" = "/path/to/ssl/cert.pem"
- "db_ssl_key" = "/path/to/ssl/key.pem"

The files mentioned should be stored on the App server in the location mentioned.

This commit allows for basic ssl connections. X509 is still not supported.

If the above options are not set, the connection will not use an encrypted connection, and connect normally.

* docs - Allow SSL to remote database host
version-14
felixvarghese 8 년 전
committed by Rushabh Mehta
부모
커밋
f189829240
2개의 변경된 파일23개의 추가작업 그리고 4개의 파일을 삭제
  1. +14
    -2
      frappe/database.py
  2. +9
    -2
      frappe/docs/user/en/guides/basics/site_config.md

+ 14
- 2
frappe/database.py 파일 보기

@@ -53,8 +53,20 @@ class Database:
def connect(self):
"""Connects to a database as set in `site_config.json`."""
warnings.filterwarnings('ignore', category=MySQLdb.Warning)
self._conn = MySQLdb.connect(user=self.user, host=self.host, passwd=self.password,
use_unicode=True, charset='utf8mb4')
usessl = 0
if frappe.conf.db_ssl_ca and frappe.conf.db_ssl_cert and frappe.conf.db_ssl_key:
usessl = 1
self.ssl = {
'ca':frappe.conf.db_ssl_ca,
'cert':frappe.conf.db_ssl_cert,
'key':frappe.conf.db_ssl_key
}
if usessl:
self._conn = MySQLdb.connect(user=self.user, host=self.host, passwd=self.password,
use_unicode=True, charset='utf8mb4', ssl=self.ssl)
else:
self._conn = MySQLdb.connect(user=self.user, host=self.host, passwd=self.password,
use_unicode=True, charset='utf8mb4')
self._conn.converter[246]=float
self._conn.converter[12]=get_datetime
self._conn.encoders[UnicodeWithAttrs] = self._conn.encoders[UnicodeType]


+ 9
- 2
frappe/docs/user/en/guides/basics/site_config.md 파일 보기

@@ -20,13 +20,20 @@ Example:

### Optional Settings

- `db_host`: Database host if not `localhost`.
- `admin_password`: Default Password for "Administrator".
- `mute_emails`: Stops email sending if true.
- `deny_multiple_logins`: Stop users from having more than one active session.
- `root_password`: MariaDB root password.

### Defaut Outgoing Email Settings
### Remote Database Host Settings
- `db_host`: Database host if not `localhost`.

To connect to a remote database server using ssl, you must first configure the database host to accept SSL connections. An example of how to do this is available at https://www.digitalocean.com/community/tutorials/how-to-configure-ssl-tls-for-mysql-on-ubuntu-16-04. After you do the configuration, set the following three options. All options must be set for Frappe to attempt to connect using SSL.
- `db_ssl_ca`: Full path to the ca.pem file used for connecting to a database host using ssl. Example value is `"/etc/mysql/ssl/ca.pem"`.
- `db_ssl_cert`: Full path to the cert.pem file used for connecting to a database host using ssl. Example value is `"/etc/mysql/ssl/client-cert.pem"`.
- `db_ssl_key`: Full path to the key.pem file used for connecting to a database host using ssl. Example value is `"/etc/mysql/ssl/client-key.pem"`.

### Default Outgoing Email Settings

- `mail_server`: SMTP server hostname.
- `mail_port`: STMP port.


불러오는 중...
취소
저장