Bug 1223107

Summary: Register RMT server failed to verify certificate during installation
Product: [openSUSE] PUBLIC SUSE Linux Enterprise Server 15 SP6 Reporter: Lemon Li <leli>
Component: OtherAssignee: Otto Hollmann <otto.hollmann>
Status: RESOLVED FIXED QA Contact:
Severity: Critical    
Priority: P2 - High CC: aj, alexander.hass, bschubert, eugenio.paolantonio, leli, lslezak, meissner, msvec, natnael.getahun, otto.hollmann, pmonrealgonzalez, rtsvetkov, tschmidt
Version: unspecifiedFlags: aj: SHIP_STOPPER? (rtsvetkov)
Target Milestone: ---   
Hardware: Other   
OS: Other   
URL: https://openqa.suse.de/tests/13923984/modules/rmt_registration_trust_import/steps/1
Whiteboard:
Found By: openQA Services Priority:
Business Priority: Blocker: Yes
Marketing QA Status: --- IT Deployment: ---
Attachments: serial0.txt
failed to verify certificate: xx509: certificate signed by unknown authority
Screenshot: Expected certificate handling in SLE-15-SP5
Screenshot: Actual certificate handling in SLE-15-SP6: Error
diff of the yast-registration source code between the SLE-15-SP5 branch and the SLE-15-SP6 branch

Description Lemon Li 2024-04-19 02:44:55 UTC
Created attachment 874366 [details]
serial0.txt

## Observation

This test failed to register to RMT server(https://migration-rmt2.qe.nue2.suse.org) for 'failed to verify certificate' during the installation of 15SP6.

While I tried to do the same test but for 15SP5, it passed. http://openqa.suse.de/tests/14058366#step/rmt_registration_trust_import/1 So the RMT server side seems good.

And after installation of 15SP5(register via SCC), register RMT server will have the same issue, http://openqa.suse.de/tests/14067586#step/register_system/5

openQA test in scenario sle-15-SP6-Migration-from-SLE15-SPx-Milestone-x86_64-rmt_server_install@64bit fails in
[rmt_registration_trust_import](https://openqa.suse.de/tests/13923984/modules/rmt_registration_trust_import/steps/1)

## Test suite description
Perform an installation using RMT server for registration, handling the subsequent trust&import popup and validating repo urls after installation. This test case would not work in Product validation when it is not a Milestone build. RMT server is only synchronized pulling new updates of packages for builds that are marked as milestones, so in any normal snapshots we will be testing packages from the previous milestone from that build.


## Reproducible

Fails since (at least) Build [73.1](https://openqa.suse.de/tests/13923984) (current job)


## Expected result

Last good: [64.2](https://openqa.suse.de/tests/13818573) (or more recent)


## Further details

Always latest result in this scenario: [latest](https://openqa.suse.de/tests/latest?arch=x86_64&distri=sle&flavor=Migration-from-SLE15-SPx-Milestone&machine=64bit&test=rmt_server_install&version=15-SP6)
Comment 1 Lemon Li 2024-04-19 02:46:48 UTC
Created attachment 874367 [details]
failed to verify certificate: xx509: certificate signed by unknown authority
Comment 2 Lemon Li 2024-04-22 01:47:34 UTC
I asked SCC team for this issue and got analysis from Thomas that :
'Hi Lemon,
the error message says that your SMT/RMT are running with self-signed certificates.
That's expected behavior. But Yast should ask the user at this point if she wants
to accept & import the certificate to proceed. That seems not to happen here,
so maybe that's a bug in yast for 15SP6. 

Thomas Schmidt (tschmidt [at] suse.de) '

Thanks Thomas, so it is better to let yast team to have a look on this issue. there is no y2log for this is a libyui test for installation, but if more logs needed please tell me to support, thanks.

Lemon
Comment 3 Radoslav Tzvetkov 2024-04-22 08:17:54 UTC
> the error message says that your SMT/RMT are running with self-signed
> certificates.
> That's expected behavior. But Yast should ask the user at this point if she
> wants
> to accept & import the certificate to proceed. That seems not to happen here,
> so maybe that's a bug in yast for 15SP6. 

As from this statement, I do not see the bug as a test blocker.
Comment 4 Stefan Hundhammer 2024-04-22 10:57:06 UTC
Created attachment 874411 [details]
Screenshot: Expected certificate handling in SLE-15-SP5

https://openqa.suse.de/tests/14058366#step/rmt_registration_trust_import/1
Comment 5 Stefan Hundhammer 2024-04-22 10:58:01 UTC
Created attachment 874412 [details]
Screenshot: Actual certificate handling in SLE-15-SP6: Error

https://openqa.suse.de/tests/13923984#step/rmt_registration_trust_import/1
Comment 6 Stefan Hundhammer 2024-04-22 10:59:11 UTC
There are no y2logs in the failing OpenQA test case:

  https://openqa.suse.de/tests/13923984#downloads

Not sure what we are expected to do here without any logs. We need something to work with.
Comment 7 Stefan Hundhammer 2024-04-22 11:21:41 UTC
Created attachment 874414 [details]
diff of the yast-registration source code between the SLE-15-SP5 branch and the SLE-15-SP6 branch

This is the result of

>> git diff upstream/SLE-15-SP5..upstream/SLE-15-SP6 src


There is no difference in the certificate handling.

Yet the error handling for that part comes from here:

  https://github.com/yast/yast-registration/blob/SLE-15-SP6/src/lib/registration/connect_helpers.rb#L130-L136

That code is unchanged for 7 years, the whole file is unchanged since 2 years.
Comment 8 Stefan Hundhammer 2024-04-22 11:33:25 UTC
According to the source code, that dialog to import the SSL certificate is shown for those error codes:

https://github.com/yast/yast-registration/blob/SLE-15-SP6/src/lib/registration/ssl_error_codes.rb#L38-L39

    SELF_SIGNED_CERT,
    SELF_SIGNED_CERT_IN_CHAIN

where

    # "self signed certificate"
    SELF_SIGNED_CERT = 18

    # "self signed certificate in certificate chain"
    SELF_SIGNED_CERT_IN_CHAIN = 19

which is consistent with the error code that we see in the SLE-15-SP5 screenshot: That one was reported as "Self signed certificate in certificate chain".

But here we have a different error: "certificate signed by unknown authority"
Comment 9 Stefan Hundhammer 2024-04-22 11:36:39 UTC
I couldn't find that error message "certificate signed by unknown authority" in any YaST code. Most likely, it comes from a rubygem or an SSL library for low-level SSL handling.

It is entirely possible that the rubygem or SSL library changed between SLE-15-SP5 and SLE-15-SP6, and that we need to adapt to that changed behavior.

But it is also possible that the certificate really has that different error in SP6.
Comment 10 Stefan Hundhammer 2024-04-22 11:38:31 UTC
And BTW that other source file ssl_error_codes.rb is also unchanged since many years, in this case 5 years:

https://github.com/yast/yast-registration/blame/SLE-15-SP6/src/lib/registration/ssl_error_codes.rb
Comment 11 Lukas Ocilka 2024-04-22 12:03:43 UTC
(In reply to Ming Li from comment #2)
> the error message says that your SMT/RMT are running with self-signed
> certificates.
> That's expected behavior. But Yast should ask the user at this point if she
> wants
> to accept & import the certificate to proceed. That seems not to happen here,
> so maybe that's a bug in yast for 15SP6. 


Let's ask Ladislav, if this is the expected behavior.

BTW, is it documented anywhere? In RMT documentation?
Comment 12 Stefan Hundhammer 2024-04-22 12:22:50 UTC
I found the message in /usr/lib64/libsuseconnect.so which is part of package libsuseconnect, a subpackage of source package suseconnect-ng.

I see a mapping of error codes (probably from libOpenSSL?) here:

https://github.com/SUSE/connect-ng/blob/main/third_party/libsuseconnect/libsuseconnect.go#L274-L282

which includes x509.UnknownAuthorityError, which is mapped to error code 19 above, SELF_SIGNED_CERT_IN_CHAIN.

I suspect that mapping doesn't work anymore. Did that change in libOpenSSL maybe?
Comment 13 Stefan Hundhammer 2024-04-22 12:49:28 UTC
The error codes are defined in /usr/include/openssl/x509_vfy.h from package libopenssl-3-devel:

# define X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT          18
# define X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN            19

My Leap 15.5  has libopenssl-3-devel-3.0.8-150500.5.27.1.x86_64,
my Tumbleweed has libopenssl-3-devel-3.1.4-5.2.x86_64,
but there doesn't seem to be a significant difference in those headers.
Comment 14 Stefan Hundhammer 2024-04-22 13:09:14 UTC
The only obvious recent code change were libsuseconnect.go:

https://github.com/SUSE/connect-ng/commits/main/third_party/libsuseconnect/libsuseconnect.go


That doesn't necessarily mean that the problem must have come from there, but it would be the first obvious place to check.

Tom, please have a look.
Comment 15 Thomas Schmidt 2024-04-23 13:21:50 UTC
How to reproduce: 

$ podman run --rm -ti registry.suse.com/suse/sle15:15.6 /bin/bash
# zypper rm -y container-suseconnect
# zypper ar -f http://updates.suse.de/SUSE/Products/SLE-Module-Basesystem/15-SP6/x86_64/product/ 156
# zypper in yast2-registration
# yast2 registration # -> register to https://rmt.scc.suse.de
Comment 16 Natnael Getahun 2024-04-23 14:19:43 UTC
Hi Stefan,
The github link you attached hasn't been released yet. But even there, we haven't made changes to the ssl error handling in over 3 years. This is the link to the release suseconnect error handling. https://github.com/SUSE/connect-ng/blob/99084c9ed4a133ea0569360b2c5d679ba8409470/libsuseconnect/libsuseconnect.go#L267
Comment 17 Thomas Schmidt 2024-04-24 13:14:54 UTC
> I see a mapping of error codes (probably from libOpenSSL?) here:
> https://github.com/SUSE/connect-ng/blob/main/third_party/libsuseconnect/libsuseconnect.go#L274-L282
> which includes x509.UnknownAuthorityError, which is mapped to error code 19 above, SELF_SIGNED_CERT_IN_CHAIN.
> I suspect that mapping doesn't work anymore. Did that change in libOpenSSL maybe?

I agree. I've tested the same suseconnect version on 15SP5, and it works as expected. 
On SP6, it seems we don't receive x509.UnknownAuthorityError, but tls.CertificateVerificationError from the system.
Comment 18 Stefan Hundhammer 2024-04-29 12:15:43 UTC
See also bug #1223107 (very likely a duplicate?)
Comment 19 Stefan Hundhammer 2024-04-29 12:23:31 UTC
*** Bug 1223528 has been marked as a duplicate of this bug. ***
Comment 21 Stefan Hundhammer 2024-04-29 12:28:26 UTC
Bug #1223528 is indeed a duplicate of this, and that one was upgrade to P1 CRITICAL by the PM.

I don't think we can handle this on the YaST side: We'd probably open a lot of security problems if we simply treated all 'tls.CertificateVerificationError' values that same way.

IMHO this is a task for the openSSL maintainers.
Comment 23 Ladislav Slezák 2024-04-29 12:32:01 UTC
JFYI, the releveant YaST part has not been changed in the last 5 years: https://github.com/yast/yast-registration/blame/SLE-15-SP6/src/lib/registration/ssl_error_codes.rb
Comment 24 Pedro Monreal Gonzalez 2024-04-29 12:35:18 UTC
I'm assigning the bug to Otto.
Comment 25 Marcus Meissner 2024-04-29 15:53:53 UTC
the underlying openssl was changed, so it might return different error codes now.
Comment 26 Pedro Monreal Gonzalez 2024-04-29 16:11:26 UTC
I'm not sure what to do from the openssl side. There might be other moving parts involved. For example, here are some recent commits in yast-registration that change the behavior in SP6+:
  * https://github.com/yast/yast-registration/commit/a407c4bb
  * https://github.com/yast/yast-registration/commit/1e0b40b1
Also, I'm not familiar with the go1.XX-openssl package an the versions involved.

Not sure what has changed between [0] (worked 1 month ago) and [1] (failed 27 days ago). Looking at openssl, it looks like the code hasn't changed in the last 2 months in SP6:GA

HTH

[0] https://openqa.suse.de/tests/13818573#step/rmt_registration_trust_import/1
[1] https://openqa.suse.de/tests/13923984#step/rmt_registration_trust_import/1
Comment 28 Stefan Hundhammer 2024-04-29 16:57:22 UTC
(In reply to Pedro Monreal Gonzalez from comment #26)
> I'm not sure what to do from the openssl side. There might be other moving
> parts involved. For example, here are some recent commits in
> yast-registration that change the behavior in SP6+:
>   * https://github.com/yast/yast-registration/commit/a407c4bb
>   * https://github.com/yast/yast-registration/commit/1e0b40b1
> Also, I'm not familiar with the go1.XX-openssl package an the versions
> involved.

See comment #10 and the comments around that one.
Comment 33 Thomas Schmidt 2024-05-02 15:26:59 UTC
suseconnect is not running into this condition (https://github.com/SUSE/connect-ng/blob/main/third_party/libsuseconnect/libsuseconnect.go#L274-L282) and not returning code 19, because it doesn't receive x509.UnknownAuthorityError anymore in SP6, but gets tls.CertificateVerificationError.
Comment 34 Radoslav Tzvetkov 2024-05-03 10:46:16 UTC
So, what is the next step?
Comment 35 Otto Hollmann 2024-05-03 12:44:32 UTC
I found that exactly this behaviour is described here
> https://github.com/golang/go/issues/59226

And it corresponds to release notes for Go 1.20
> https://go.dev/doc/go1.20#crypto/tls

> For a handshake failure due to a certificate verification failure, the TLS
> client and server now return an error of the new type
> CertificateVerificationError, which includes the presented certificates.

Is it possible that Go has been upgraded in the meantime?
Comment 37 Lemon Li 2024-05-06 02:19:22 UTC
I rerun the test on build 82.1 and got the same issue. http://openqa.suse.de/tests/14212028#step/rmt_registration_trust_import/1

As [comments #35] (https://bugzilla.suse.com/show_bug.cgi?id=1223107#c35) and [comments #36](https://bugzilla.suse.com/show_bug.cgi?id=1223107#c36), the issue seems comes from Go script.
Comment 38 Marcus Meissner 2024-05-06 14:41:06 UTC
Thomas, can you handle this tls.CertificateVerificationError  

in thirdparty/libsuseconnect/libsuseconnect.go

same as SSLError and return error 19
Comment 41 Thomas Schmidt 2024-05-07 15:13:35 UTC
Could you run a test with the package from https://build.opensuse.org/package/show/systemsmanagement:SCC/suseconnect-ng? We fixed the certificate issue in that build.
Comment 42 Lemon Li 2024-05-08 05:35:34 UTC
(In reply to Thomas Schmidt from comment #41)
> Could you run a test with the package from
> https://build.opensuse.org/package/show/systemsmanagement:SCC/suseconnect-
> ng? We fixed the certificate issue in that build.

Hi Thomas, I tried to install the updated pkg suseconnect-ng-1.9.0-150300.92.1.x86_64 http://openqa.suse.de/tests/14233856#step/register_system/6, but it still failed to verify certification http://openqa.suse.de/tests/14233856#step/register_system/11 . Is there anything wrong for my test?

Lemon
Comment 43 Thomas Schmidt 2024-05-08 07:46:48 UTC
Hi @Ming Li, the fix is in the package libsuseconnect-1.9.0. Please update all the packages suseconnect-ruby-bindings-1.9.0, suseconnect-ng-1.9.0, libsuseconnect-1.9.0.
Comment 44 Lemon Li 2024-05-08 08:53:14 UTC
(In reply to Thomas Schmidt from comment #43)
> Hi @Ming Li, the fix is in the package libsuseconnect-1.9.0. Please update
> all the packages suseconnect-ruby-bindings-1.9.0, suseconnect-ng-1.9.0,
> libsuseconnect-1.9.0.

Hi Thomas, after updated these pkgs, the certification for RMT server works now. http://openqa.suse.de/tests/14235073#step/register_system/15
Comment 45 Thomas Schmidt 2024-05-08 09:17:02 UTC
fixed package submitted to 15SP6: https://build.suse.de/request/show/329584
Comment 47 Stefan Hundhammer 2024-05-13 08:24:24 UTC
I think this can be closed as FIXED now.
Comment 48 Thomas Schmidt 2024-05-13 08:28:58 UTC
Fixed in libsuseconnect-1.9.0
Comment 51 Maintenance Automation 2024-05-27 20:30:07 UTC
SUSE-RU-2024:1792-1: An update that has two fixes can now be installed.

Category: recommended (important)
Bug References: 1220679, 1223107
Maintenance Incident: [SUSE:Maintenance:33842](https://smelt.suse.de/incident/33842/)
Sources used:
SUSE Linux Enterprise Server 15 SP2 (src):
 suseconnect-ng-1.9.0-150100.3.26.3
SUSE Linux Enterprise High Performance Computing 15 SP2 LTSS 15-SP2 (src):
 suseconnect-ng-1.9.0-150100.3.26.3
SUSE Linux Enterprise High Performance Computing LTSS 15 SP3 (src):
 suseconnect-ng-1.9.0-150100.3.26.3
SUSE Linux Enterprise Server 15 SP2 LTSS 15-SP2 (src):
 suseconnect-ng-1.9.0-150100.3.26.3
SUSE Linux Enterprise Server 15 SP3 LTSS 15-SP3 (src):
 suseconnect-ng-1.9.0-150100.3.26.3
SUSE Linux Enterprise Server for SAP Applications 15 SP2 (src):
 suseconnect-ng-1.9.0-150100.3.26.3
SUSE Linux Enterprise Server for SAP Applications 15 SP3 (src):
 suseconnect-ng-1.9.0-150100.3.26.3
SUSE Enterprise Storage 7.1 (src):
 suseconnect-ng-1.9.0-150100.3.26.3

NOTE: This line indicates an update has been released for the listed product(s). At times this might be only a partial fix. If you have questions please reach out to maintenance coordination.
Comment 52 Maintenance Automation 2024-05-28 16:30:13 UTC
SUSE-RU-2024:1800-1: An update that has two fixes can now be installed.

Category: recommended (moderate)
Bug References: 1220679, 1223107
Maintenance Incident: [SUSE:Maintenance:33841](https://smelt.suse.de/incident/33841/)
Sources used:
SUSE Linux Enterprise Micro 5.1 (src):
 suseconnect-ng-1.9.0-150300.3.20.2

NOTE: This line indicates an update has been released for the listed product(s). At times this might be only a partial fix. If you have questions please reach out to maintenance coordination.
Comment 53 Maintenance Automation 2024-05-28 16:30:15 UTC
SUSE-RU-2024:1799-1: An update that has two fixes can now be installed.

Category: recommended (moderate)
Bug References: 1220679, 1223107
Maintenance Incident: [SUSE:Maintenance:33832](https://smelt.suse.de/incident/33832/)
Sources used:
openSUSE Leap 15.5 (src):
 suseconnect-ng-1.9.0-150500.3.21.2
SUSE Linux Enterprise Micro 5.5 (src):
 suseconnect-ng-1.9.0-150500.3.21.2
Basesystem Module 15-SP5 (src):
 suseconnect-ng-1.9.0-150500.3.21.2

NOTE: This line indicates an update has been released for the listed product(s). At times this might be only a partial fix. If you have questions please reach out to maintenance coordination.
Comment 54 Maintenance Automation 2024-05-29 08:30:04 UTC
SUSE-RU-2024:1811-1: An update that has two fixes can now be installed.

Category: recommended (moderate)
Bug References: 1220679, 1223107
Maintenance Incident: [SUSE:Maintenance:33836](https://smelt.suse.de/incident/33836/)
Sources used:
SUSE Linux Enterprise Micro 5.2 (src):
 suseconnect-ng-1.9.0-150300.3.15.2
SUSE Linux Enterprise Micro for Rancher 5.2 (src):
 suseconnect-ng-1.9.0-150300.3.15.2

NOTE: This line indicates an update has been released for the listed product(s). At times this might be only a partial fix. If you have questions please reach out to maintenance coordination.
Comment 55 Maintenance Automation 2024-05-29 16:30:02 UTC
SUSE-RU-2024:1839-1: An update that has two fixes can now be installed.

Category: recommended (important)
Bug References: 1220679, 1223107
Maintenance Incident: [SUSE:Maintenance:33843](https://smelt.suse.de/incident/33843/)
Sources used:
SUSE Linux Enterprise High Performance Computing 12 SP5 (src):
 suseconnect-ng-1.9.0-3.15.4
SUSE Linux Enterprise Server 12 SP5 (src):
 suseconnect-ng-1.9.0-3.15.4
SUSE Linux Enterprise Server for SAP Applications 12 SP5 (src):
 suseconnect-ng-1.9.0-3.15.4

NOTE: This line indicates an update has been released for the listed product(s). At times this might be only a partial fix. If you have questions please reach out to maintenance coordination.
Comment 56 Maintenance Automation 2024-06-10 20:30:26 UTC
SUSE-RU-2024:1940-1: An update that has two fixes can now be installed.

Category: recommended (moderate)
Bug References: 1220679, 1223107
Maintenance Incident: [SUSE:Maintenance:33835](https://smelt.suse.de/incident/33835/)
Sources used:
openSUSE Leap 15.4 (src):
 suseconnect-ng-1.9.0-150400.3.31.2
openSUSE Leap Micro 5.3 (src):
 suseconnect-ng-1.9.0-150400.3.31.2
openSUSE Leap Micro 5.4 (src):
 suseconnect-ng-1.9.0-150400.3.31.2
SUSE Linux Enterprise Micro for Rancher 5.3 (src):
 suseconnect-ng-1.9.0-150400.3.31.2
SUSE Linux Enterprise Micro 5.3 (src):
 suseconnect-ng-1.9.0-150400.3.31.2
SUSE Linux Enterprise Micro for Rancher 5.4 (src):
 suseconnect-ng-1.9.0-150400.3.31.2
SUSE Linux Enterprise Micro 5.4 (src):
 suseconnect-ng-1.9.0-150400.3.31.2
SUSE Linux Enterprise High Performance Computing ESPOS 15 SP4 (src):
 suseconnect-ng-1.9.0-150400.3.31.2
SUSE Linux Enterprise High Performance Computing LTSS 15 SP4 (src):
 suseconnect-ng-1.9.0-150400.3.31.2
SUSE Linux Enterprise Desktop 15 SP4 LTSS 15-SP4 (src):
 suseconnect-ng-1.9.0-150400.3.31.2
SUSE Linux Enterprise Server 15 SP4 LTSS 15-SP4 (src):
 suseconnect-ng-1.9.0-150400.3.31.2
SUSE Linux Enterprise Server for SAP Applications 15 SP4 (src):
 suseconnect-ng-1.9.0-150400.3.31.2
SUSE Manager Proxy 4.3 (src):
 suseconnect-ng-1.9.0-150400.3.31.2
SUSE Manager Retail Branch Server 4.3 (src):
 suseconnect-ng-1.9.0-150400.3.31.2
SUSE Manager Server 4.3 (src):
 suseconnect-ng-1.9.0-150400.3.31.2

NOTE: This line indicates an update has been released for the listed product(s). At times this might be only a partial fix. If you have questions please reach out to maintenance coordination.