Show invalid certificate screen also when registering account
This commit is contained in:
parent
81a5505270
commit
c7b242a72e
|
@ -124,7 +124,14 @@ public class Register : StreamInteractionModule, Object{
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Xep.InBandRegistration.Form? get_registration_form(Jid jid) {
|
public class RegistrationFormReturn {
|
||||||
|
public Xep.InBandRegistration.Form? form { get; set; }
|
||||||
|
public TlsCertificateFlags? error_flags { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async RegistrationFormReturn get_registration_form(Jid jid) {
|
||||||
|
RegistrationFormReturn ret = new RegistrationFormReturn();
|
||||||
|
|
||||||
Gee.List<XmppStreamModule> list = new ArrayList<XmppStreamModule>();
|
Gee.List<XmppStreamModule> list = new ArrayList<XmppStreamModule>();
|
||||||
list.add(new Iq.Module());
|
list.add(new Iq.Module());
|
||||||
list.add(new Xep.InBandRegistration.Module());
|
list.add(new Xep.InBandRegistration.Module());
|
||||||
|
@ -134,7 +141,13 @@ public class Register : StreamInteractionModule, Object{
|
||||||
);
|
);
|
||||||
|
|
||||||
if (stream_result.stream == null) {
|
if (stream_result.stream == null) {
|
||||||
return null;
|
if (stream_result.io_error != null) {
|
||||||
|
debug("Error connecting to stream: %s", stream_result.io_error.message);
|
||||||
|
}
|
||||||
|
if (stream_result.tls_errors != null) {
|
||||||
|
ret.error_flags = stream_result.tls_errors;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
XmppStream stream = stream_result.stream;
|
XmppStream stream = stream_result.stream;
|
||||||
|
|
||||||
|
@ -159,15 +172,14 @@ public class Register : StreamInteractionModule, Object{
|
||||||
|
|
||||||
yield;
|
yield;
|
||||||
|
|
||||||
Xep.InBandRegistration.Form? form = null;
|
|
||||||
if (stream.negotiation_complete) {
|
if (stream.negotiation_complete) {
|
||||||
form = yield stream.get_module(Xep.InBandRegistration.Module.IDENTITY).get_from_server(stream, jid);
|
ret.form = yield stream.get_module(Xep.InBandRegistration.Module.IDENTITY).get_from_server(stream, jid);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
yield stream.disconnect();
|
yield stream.disconnect();
|
||||||
} catch (Error e) {}
|
} catch (Error e) {}
|
||||||
|
|
||||||
return form;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async string? submit_form(Jid jid, Xep.InBandRegistration.Form form) {
|
public static async string? submit_form(Jid jid, Xep.InBandRegistration.Form form) {
|
||||||
|
|
|
@ -141,7 +141,7 @@ public class AddAccountDialog : Gtk.Dialog {
|
||||||
animate_window_resize(sign_in_jid_box);
|
animate_window_resize(sign_in_jid_box);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void show_tls_error() {
|
private void show_tls_error(string domain, TlsCertificateFlags error_flags) {
|
||||||
sign_in_tls_box.visible = true;
|
sign_in_tls_box.visible = true;
|
||||||
stack.visible_child_name = "tls_error";
|
stack.visible_child_name = "tls_error";
|
||||||
sign_in_jid_box.visible = false;
|
sign_in_jid_box.visible = false;
|
||||||
|
@ -149,6 +149,20 @@ public class AddAccountDialog : Gtk.Dialog {
|
||||||
create_account_box.visible = false;
|
create_account_box.visible = false;
|
||||||
register_box.visible = false;
|
register_box.visible = false;
|
||||||
success_box.visible = false;
|
success_box.visible = false;
|
||||||
|
|
||||||
|
string error_desc = _("The server could not prove that it is %s.").printf("<b>" + domain + "</b>");
|
||||||
|
if (TlsCertificateFlags.UNKNOWN_CA in error_flags) {
|
||||||
|
error_desc += " " + _("Its security certificate is not trusted by your operating system.");
|
||||||
|
} else if (TlsCertificateFlags.BAD_IDENTITY in error_flags) {
|
||||||
|
error_desc += " " + _("Its security certificate is issued to another domain.");
|
||||||
|
} else if (TlsCertificateFlags.NOT_ACTIVATED in error_flags) {
|
||||||
|
error_desc += " " + _("Its security certificate will only become valid in the future.");
|
||||||
|
} else if (TlsCertificateFlags.EXPIRED in error_flags) {
|
||||||
|
error_desc += " " + _("Its security certificate is expired.");
|
||||||
|
}
|
||||||
|
sign_in_tls_label.label = error_desc;
|
||||||
|
|
||||||
|
animate_window_resize(sign_in_tls_box);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void show_sign_in_password() {
|
private void show_sign_in_password() {
|
||||||
|
@ -242,18 +256,7 @@ public class AddAccountDialog : Gtk.Dialog {
|
||||||
} else {
|
} else {
|
||||||
jid_entry.sensitive = true;
|
jid_entry.sensitive = true;
|
||||||
if (server_status.error_flags != null) {
|
if (server_status.error_flags != null) {
|
||||||
string error_desc = _("The server could not prove that it is %s.").printf("<b>" + login_jid.domainpart + "</b>");
|
show_tls_error(login_jid.domainpart, server_status.error_flags);
|
||||||
if (TlsCertificateFlags.UNKNOWN_CA in server_status.error_flags) {
|
|
||||||
error_desc += " " + _("Its security certificate is not trusted by your operating system.");
|
|
||||||
} else if (TlsCertificateFlags.BAD_IDENTITY in server_status.error_flags) {
|
|
||||||
error_desc += " " + _("Its security certificate is issued to another domain.");
|
|
||||||
} else if (TlsCertificateFlags.NOT_ACTIVATED in server_status.error_flags) {
|
|
||||||
error_desc += " " + _("Its security certificate will only become valid in the future.");
|
|
||||||
} else if (TlsCertificateFlags.EXPIRED in server_status.error_flags) {
|
|
||||||
error_desc += " " + _("Its security certificate is expired.");
|
|
||||||
}
|
|
||||||
sign_in_tls_label.label = error_desc;
|
|
||||||
show_tls_error();
|
|
||||||
} else {
|
} else {
|
||||||
sign_in_jid_error_label.label = _("Could not connect to %s").printf(login_jid.domainpart);
|
sign_in_jid_error_label.label = _("Could not connect to %s").printf(login_jid.domainpart);
|
||||||
}
|
}
|
||||||
|
@ -290,7 +293,7 @@ public class AddAccountDialog : Gtk.Dialog {
|
||||||
private void on_select_server_continue() {
|
private void on_select_server_continue() {
|
||||||
try {
|
try {
|
||||||
server_jid = new Jid(server_entry.text);
|
server_jid = new Jid(server_entry.text);
|
||||||
request_show_register_form.begin();
|
request_show_register_form.begin(server_jid);
|
||||||
} catch (InvalidJidError e) {
|
} catch (InvalidJidError e) {
|
||||||
warning("Invalid address from interface allowed server: %s", e.message);
|
warning("Invalid address from interface allowed server: %s", e.message);
|
||||||
display_notification(_("Invalid address"));
|
display_notification(_("Invalid address"));
|
||||||
|
@ -300,23 +303,26 @@ public class AddAccountDialog : Gtk.Dialog {
|
||||||
private void on_server_list_row_activated(ListBox box, ListBoxRow row) {
|
private void on_server_list_row_activated(ListBox box, ListBoxRow row) {
|
||||||
try {
|
try {
|
||||||
server_jid = new Jid(list_box_jids[row]);
|
server_jid = new Jid(list_box_jids[row]);
|
||||||
request_show_register_form.begin();
|
request_show_register_form.begin(server_jid);
|
||||||
} catch (InvalidJidError e) {
|
} catch (InvalidJidError e) {
|
||||||
warning("Invalid address from selected server: %s", e.message);
|
warning("Invalid address from selected server: %s", e.message);
|
||||||
display_notification(_("Invalid address"));
|
display_notification(_("Invalid address"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void request_show_register_form() {
|
private async void request_show_register_form(Jid server_jid) {
|
||||||
select_server_continue_stack.visible_child_name = "spinner";
|
select_server_continue_stack.visible_child_name = "spinner";
|
||||||
form = yield Register.get_registration_form(server_jid);
|
Register.RegistrationFormReturn form_return = yield Register.get_registration_form(server_jid);
|
||||||
if (select_server_continue_stack == null) {
|
if (select_server_continue_stack == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
select_server_continue_stack.visible_child_name = "label";
|
select_server_continue_stack.visible_child_name = "label";
|
||||||
if (form != null) {
|
if (form_return.form != null) {
|
||||||
|
form = form_return.form;
|
||||||
set_register_form(server_jid, form);
|
set_register_form(server_jid, form);
|
||||||
show_register_form();
|
show_register_form();
|
||||||
|
} else if (form_return.error_flags != null) {
|
||||||
|
show_tls_error(server_jid.domainpart, form_return.error_flags);
|
||||||
} else {
|
} else {
|
||||||
display_notification(_("No response from server"));
|
display_notification(_("No response from server"));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue