Skip to content

Commit

Permalink
translate openSSL error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
lslezak committed Apr 30, 2014
1 parent 796cb20 commit 42ff9c7
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 11 deletions.
8 changes: 7 additions & 1 deletion src/data/registration/certificate_summary.erb
Expand Up @@ -11,7 +11,7 @@ textdomain "registration"
<p>
<% # label followed by error details
%>
<%= _("Error:") %> <%= h(Storage::SSLErrors.instance.ssl_error_msg) %>
<%= _("Details:") %> <%= _(OPENSSL_ERROR_MESSAGES[Storage::SSLErrors.instance.ssl_error_code]) %>
</p>

<% # dialog sub-heading
Expand Down Expand Up @@ -54,6 +54,12 @@ textdomain "registration"
<% # label followed by the certificate issue date
%>
<b><%= _("Issued On:") %></b> <%= h(@certificate.not_before.localtime.strftime("%F")) %><br>
<% if Time.now < @certificate.not_before %>
<% # warning added after the certificate issue date
# if the certificate is not valid yet
%>
<b><font color="red"><%= _("WARNING: The certificate is not valid yet!") %></font></b><br>
<% end %>
<% # label followed by the certificate expiration date
%>
<b><%= _("Expires On:") %></b> <%= h(@certificate.not_after.localtime.strftime("%F")) %><br>
Expand Down
8 changes: 3 additions & 5 deletions src/lib/registration/connect_helpers.rb
Expand Up @@ -38,10 +38,7 @@ class SccHelpers
# openSSL error codes for which the import SSL certificate dialog is shown,
# for the other error codes just the error message is displayed
# (importing the certificate would not help)
# 18 = "self signed certificate"
# 19 = "self signed certificate in certificate chain"
# @see https://www.openssl.org/docs/apps/verify.html
IMPORT_ERROR_CODES = [ 18, 19 ]
IMPORT_ERROR_CODES = UI::ImportCertificateDialog::OPENSSL_ERROR_MESSAGES.keys

textdomain "registration"

Expand Down Expand Up @@ -132,6 +129,7 @@ def self.report_error(msg, api_error)
def self.error_with_details(error, details)
return error if (!details || details.empty?)

# %s are error details
error + "\n\n" + (_("Details: %s") % details)
end

Expand All @@ -157,7 +155,7 @@ def self.ssl_error_details()
end

def self.import_ssl_certificate(cert)
if UI::ImportCertificateDialog.run(cert) == :import
if UI::ImportCertificateDialog.run(cert) == :import
result = Yast::Popup.Feedback(_("Importing the SSL certificate..."), "") do
::SUSE::Connect::SSLCertificate.import(cert)
end
Expand Down
21 changes: 16 additions & 5 deletions src/lib/registration/ui/import_certificate_dialog.rb
Expand Up @@ -8,11 +8,22 @@ module UI
class ImportCertificateDialog
include Yast::Logger
include Yast::I18n
extend Yast::I18n
include Yast::UIShortcuts
include ERB::Util

attr_accessor :certificate

# error code => translatable error message
# @see https://www.openssl.org/docs/apps/verify.html
# @note the text messages need to be translated at runtime via _() call
OPENSSL_ERROR_MESSAGES = {
# SSL error message
18 => N_("Self signed certificate"),
# SSL error message
19 => N_("Self signed certificate in certificate chain")
}

Yast.import "UI"
Yast.import "Label"

Expand Down Expand Up @@ -95,22 +106,22 @@ def warning_text
_("<p>Secure connection (HTTPS) uses SSL certificates for verifying the " \
"authenticity of the server and for encrypting the transferred data.</p>") +

# help text for importing a SSL certificate (2/5)
# help text for importing a SSL certificate (2/5)
_("<p>You can choose to import the certificate it into the list of known " \
"certificate autohorities (CA), meaning that you trust the subject " \
"and the issuer of the unknown certificate.</p>") +

# help text for importing a SSL certificate (3/5)
# help text for importing a SSL certificate (3/5)
_("<p>Importing a certificate will allow to use for example a " \
"self-signed certificate.</p>") +

# help text for importing a SSL certificate (4/5)
# help text for importing a SSL certificate (4/5)
_("<p><b>Important:</b> You should verify SHA1 fingerprint of the " \
"certificate to be sure you import the genuine certificate from " \
"the requested server.</p>") +

# help text for importing a SSL certificate (5/5)
_("<p><b>Importing an unknown certificate without " \
# help text for importing a SSL certificate (5/5)
_("<p><b>Importing an unknown certificate without " \
"verification is a big security risk.</b></p>")
end

Expand Down

0 comments on commit 42ff9c7

Please sign in to comment.