Merge pull request #1096 from deltachat/hostname_certificate_validation

Hostname / certificate validation
This commit is contained in:
björn petersen
2019-11-01 01:19:49 +01:00
committed by GitHub
4 changed files with 46 additions and 11 deletions
+21 -2
View File
@@ -90,7 +90,7 @@
android:layout_height="wrap_content"
android:visibility="gone"
app:constraint_referenced_ids="inbox, imap_login, imap_server, imap_port, imap_security_label, imap_security, outbox_view_spacer_top,
outbox, smtp_login, smtp_password, smtp_server, smtp_port, smtp_security_label, smtp_security, auth_method_label, auth_method, view_log_button" />
outbox, smtp_login, smtp_password, smtp_server, smtp_port, smtp_security_label, smtp_security, auth_method_label, auth_method, cert_check_label, cert_check, view_log_button" />
<ImageView
android:id="@+id/advanced_icon"
@@ -323,6 +323,25 @@
app:layout_constraintStart_toStartOf="@id/guideline_root_start"
app:layout_constraintTop_toBottomOf="@id/auth_method_label" />
<TextView
android:id="@+id/cert_check_label"
style="@style/TextAppearance.AppCompat.Caption"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/login_certificate_checks"
app:layout_constraintEnd_toEndOf="@id/guideline_root_end"
app:layout_constraintStart_toStartOf="@id/guideline_root_start"
app:layout_constraintTop_toBottomOf="@id/auth_method" />
<Spinner
android:id="@+id/cert_check"
android:layout_width="0dp"
android:layout_height="48dp"
android:entries="@array/pref_dc_certck_entries"
app:layout_constraintEnd_toEndOf="@id/guideline_root_end"
app:layout_constraintStart_toStartOf="@id/guideline_root_start"
app:layout_constraintTop_toBottomOf="@id/cert_check_label" />
<TextView
android:id="@+id/view_log_button"
android:layout_width="0dp"
@@ -335,7 +354,7 @@
android:paddingBottom="32dp"
app:layout_constraintEnd_toEndOf="@id/guideline_root_end"
app:layout_constraintStart_toStartOf="@id/guideline_root_start"
app:layout_constraintTop_toBottomOf="@id/auth_method" />
app:layout_constraintTop_toBottomOf="@id/cert_check" />
<TextView
android:id="@+id/sub_header"
+7
View File
@@ -178,6 +178,13 @@
<item>1</item>
</string-array>
<string-array name="pref_dc_certck_entries">
<item>@string/automatic</item>
<item>@string/strict</item>
<item>@string/accept_invalid_hostnames</item>
<item>@string/accept_invalid_certificates</item>
</string-array>
<!-- discrete MIME type (the part before the "/") -->
+1
View File
@@ -328,6 +328,7 @@
<string name="login_info_oauth2_title">Continue with simplified setup?</string>
<string name="login_info_oauth2_text">The entered e-mail-address supports a simplified setup (OAuth2).\n\nIn the next step, please allow Delta Chat to act as your Chat with E-Mail app.\n\nThere are no Delta Chat servers, your data stays on your device!</string>
<string name="login_info_gmail_text">For GMail Accounts you need to create an App-Password if you have 2FA enabled. If this setting is not available, you need to enable Less Secure Apps.</string>
<string name="login_certificate_checks">Certificate checks</string>
<string name="login_error_mail">Please enter a valid email address</string>
<string name="login_error_server">Please enter a valid server / IP address</string>
<string name="login_error_port">Please enter a valid port (1–65535)</string>
@@ -67,6 +67,7 @@ public class RegistrationActivity extends BaseActionBarActivity implements DcEve
Spinner imapSecurity;
Spinner smtpSecurity;
Spinner authMethod;
Spinner certCheck;
@Override
public void onCreate(Bundle bundle) {
@@ -89,6 +90,7 @@ public class RegistrationActivity extends BaseActionBarActivity implements DcEve
imapSecurity = findViewById(R.id.imap_security);
smtpSecurity = findViewById(R.id.smtp_security);
authMethod = findViewById(R.id.auth_method);
certCheck = findViewById(R.id.cert_check);
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
@@ -132,26 +134,29 @@ public class RegistrationActivity extends BaseActionBarActivity implements DcEve
smtpServerInput.setText(DcHelper.get(this, CONFIG_SEND_SERVER));
smtpPortInput.setText(DcHelper.get(this, CONFIG_SEND_PORT));
int server_flags = DcHelper.getInt(this, "server_flags", 0);
int serverFlags = DcHelper.getInt(this, "server_flags", 0);
int sel = 0;
if((server_flags&DcContext.DC_LP_IMAP_SOCKET_SSL)!=0) sel = 1;
if((server_flags&DcContext.DC_LP_IMAP_SOCKET_STARTTLS)!=0) sel = 2;
if((server_flags&DcContext.DC_LP_IMAP_SOCKET_PLAIN)!=0) sel = 3;
if((serverFlags&DcContext.DC_LP_IMAP_SOCKET_SSL)!=0) sel = 1;
if((serverFlags&DcContext.DC_LP_IMAP_SOCKET_STARTTLS)!=0) sel = 2;
if((serverFlags&DcContext.DC_LP_IMAP_SOCKET_PLAIN)!=0) sel = 3;
imapSecurity.setSelection(sel);
sel = 0;
if((server_flags&DcContext.DC_LP_SMTP_SOCKET_SSL)!=0) sel = 1;
if((server_flags&DcContext.DC_LP_SMTP_SOCKET_STARTTLS)!=0) sel = 2;
if((server_flags&DcContext.DC_LP_SMTP_SOCKET_PLAIN)!=0) sel = 3;
if((serverFlags&DcContext.DC_LP_SMTP_SOCKET_SSL)!=0) sel = 1;
if((serverFlags&DcContext.DC_LP_SMTP_SOCKET_STARTTLS)!=0) sel = 2;
if((serverFlags&DcContext.DC_LP_SMTP_SOCKET_PLAIN)!=0) sel = 3;
smtpSecurity.setSelection(sel);
sel = 0;
if((server_flags&DcContext.DC_LP_AUTH_OAUTH2)!=0) sel = 1;
if((serverFlags&DcContext.DC_LP_AUTH_OAUTH2)!=0) sel = 1;
authMethod.setSelection(sel);
int certCheckFlags = DcHelper.getInt(this, "imap_certificate_checks");
certCheck.setSelection(certCheckFlags);
}
DcHelper.getContext(this).eventCenter.addObserver(this, DcContext.DC_EVENT_CONFIGURE_PROGRESS);
DcHelper.getContext(this).eventCenter.addObserver(DcContext.DC_EVENT_CONFIGURE_PROGRESS, this);
}
@Override
@@ -434,6 +439,9 @@ public class RegistrationActivity extends BaseActionBarActivity implements DcEve
if(authMethod.getSelectedItemPosition()==1) server_flags |= DcContext.DC_LP_AUTH_OAUTH2;
DcHelper.getContext(this).setConfigInt("server_flags", server_flags);
DcHelper.getContext(this).setConfigInt("smtp_certificate_checks", certCheck.getSelectedItemPosition());
DcHelper.getContext(this).setConfigInt("imap_certificate_checks", certCheck.getSelectedItemPosition());
// calling configure() results in
// receiving multiple DC_EVENT_CONFIGURE_PROGRESS events
DcHelper.getContext(this).captureNextError();