mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 01:16:31 +03:00
Add constants for certificate checks configuration
This commit is contained in:
committed by
Floris Bruynooghe
parent
cfa69cf35a
commit
c85f1b20ca
@@ -3879,7 +3879,43 @@ int64_t dc_lot_get_timestamp (const dc_lot_t* lot);
|
|||||||
#define DC_LP_IMAP_SOCKET_FLAGS (DC_LP_IMAP_SOCKET_STARTTLS|DC_LP_IMAP_SOCKET_SSL|DC_LP_IMAP_SOCKET_PLAIN) // if none of these flags are set, the default is chosen
|
#define DC_LP_IMAP_SOCKET_FLAGS (DC_LP_IMAP_SOCKET_STARTTLS|DC_LP_IMAP_SOCKET_SSL|DC_LP_IMAP_SOCKET_PLAIN) // if none of these flags are set, the default is chosen
|
||||||
#define DC_LP_SMTP_SOCKET_FLAGS (DC_LP_SMTP_SOCKET_STARTTLS|DC_LP_SMTP_SOCKET_SSL|DC_LP_SMTP_SOCKET_PLAIN) // if none of these flags are set, the default is chosen
|
#define DC_LP_SMTP_SOCKET_FLAGS (DC_LP_SMTP_SOCKET_STARTTLS|DC_LP_SMTP_SOCKET_SSL|DC_LP_SMTP_SOCKET_PLAIN) // if none of these flags are set, the default is chosen
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @defgroup DC_CERTCK DC_CERTCK
|
||||||
|
*
|
||||||
|
* These constants configure TLS certificate checks for IMAP and SMTP connections.
|
||||||
|
*
|
||||||
|
* These constants are set via dc_set_config
|
||||||
|
* using keys "imap_certificate_checks" and "smtp_certificate_checks".
|
||||||
|
*
|
||||||
|
* @addtogroup DC_CERTCK
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configure certificate checks automatically.
|
||||||
|
*/
|
||||||
|
#define DC_CERTCK_AUTO 0
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Strictly check TLS certificates.
|
||||||
|
* Require that both the certificate and hostname are valid.
|
||||||
|
*/
|
||||||
|
#define DC_CERTCK_STRICT 1
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Accept invalid hostnames, but not invalid certificates.
|
||||||
|
*/
|
||||||
|
#define DC_CERTCK_ACCEPT_INVALID_HOSTNAMES 2
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Accept invalid certificates, including self-signed ones
|
||||||
|
* or having incorrect hostname.
|
||||||
|
*/
|
||||||
|
#define DC_CERTCK_ACCEPT_INVALID_CERTIFICATES 3
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @defgroup DC_EVENT DC_EVENT
|
* @defgroup DC_EVENT DC_EVENT
|
||||||
|
|||||||
@@ -65,6 +65,10 @@ DC_LP_IMAP_SOCKET_PLAIN = 0x400
|
|||||||
DC_LP_SMTP_SOCKET_STARTTLS = 0x10000
|
DC_LP_SMTP_SOCKET_STARTTLS = 0x10000
|
||||||
DC_LP_SMTP_SOCKET_SSL = 0x20000
|
DC_LP_SMTP_SOCKET_SSL = 0x20000
|
||||||
DC_LP_SMTP_SOCKET_PLAIN = 0x40000
|
DC_LP_SMTP_SOCKET_PLAIN = 0x40000
|
||||||
|
DC_CERTCK_AUTO = 0
|
||||||
|
DC_CERTCK_STRICT = 1
|
||||||
|
DC_CERTCK_ACCEPT_INVALID_HOSTNAMES = 2
|
||||||
|
DC_CERTCK_ACCEPT_INVALID_CERTIFICATES = 3
|
||||||
DC_EVENT_INFO = 100
|
DC_EVENT_INFO = 100
|
||||||
DC_EVENT_SMTP_CONNECTED = 101
|
DC_EVENT_SMTP_CONNECTED = 101
|
||||||
DC_EVENT_IMAP_CONNECTED = 102
|
DC_EVENT_IMAP_CONNECTED = 102
|
||||||
@@ -147,8 +151,8 @@ DC_STR_COUNT = 67
|
|||||||
|
|
||||||
|
|
||||||
def read_event_defines(f):
|
def read_event_defines(f):
|
||||||
rex = re.compile(r'#define\s+((?:DC_EVENT_|DC_QR|DC_MSG|DC_LP|DC_STATE_|DC_STR|'
|
rex = re.compile(r'#define\s+((?:DC_EVENT|DC_QR|DC_MSG|DC_LP|DC_CERTCK|DC_STATE|DC_STR|'
|
||||||
r'DC_CONTACT_ID_|DC_GCL|DC_CHAT|DC_PROVIDER)\S+)\s+([x\d]+).*')
|
r'DC_CONTACT_ID|DC_GCL|DC_CHAT|DC_PROVIDER)_\S+)\s+([x\d]+).*')
|
||||||
for line in f:
|
for line in f:
|
||||||
m = rex.match(line)
|
m = rex.match(line)
|
||||||
if m:
|
if m:
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import pytest
|
|||||||
import requests
|
import requests
|
||||||
import time
|
import time
|
||||||
from deltachat import Account
|
from deltachat import Account
|
||||||
|
from deltachat import const
|
||||||
from deltachat.capi import lib
|
from deltachat.capi import lib
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
@@ -164,8 +165,8 @@ def acfactory(pytestconfig, tmpdir, request, session_liveconfig):
|
|||||||
configdict["e2ee_enabled"] = "1"
|
configdict["e2ee_enabled"] = "1"
|
||||||
|
|
||||||
# Enable strict certificate checks for online accounts
|
# Enable strict certificate checks for online accounts
|
||||||
configdict["imap_certificate_checks"] = "1"
|
configdict["imap_certificate_checks"] = str(const.DC_CERTCK_STRICT)
|
||||||
configdict["smtp_certificate_checks"] = "1"
|
configdict["smtp_certificate_checks"] = str(const.DC_CERTCK_STRICT)
|
||||||
|
|
||||||
tmpdb = tmpdir.join("livedb%d" % self.live_count)
|
tmpdb = tmpdir.join("livedb%d" % self.live_count)
|
||||||
ac = self.make_account(tmpdb.strpath, logid="ac{}".format(self.live_count))
|
ac = self.make_account(tmpdb.strpath, logid="ac{}".format(self.live_count))
|
||||||
|
|||||||
Reference in New Issue
Block a user