Hello, it seems that on znc v1.8 certauth module is broken. It cant get certificate sent by clients.
This GetKey() function returns status 20.
Also, I’m using LibreSSL 3.2.2.
Built ZNC with it and generated certificate with it too.
I’m running on Gentoo for you to get the build environment.
I looked a little on sources and it comes from https://github.com/znc/znc/blob/6cd80535c064e91155468e79f50fc1c3f3c0f3e5/modules/certauth.cpp#L221
Some debug logs:
Hello, it seems that on znc v1.8 certauth module is broken. It cant get certificate sent by clients.
This GetKey() function returns status 20.
Also, I’m using LibreSSL 3.2.2.
Built ZNC with it and generated certificate with it too.
I’m running on Gentoo for you to get the build environment.
I looked a little on sources and it comes from https://github.com/znc/znc/blob/6cd80535c064e91155468e79f50fc1c3f3c0f3e5/modules/certauth.cpp#L221
Some debug logs:
```
[2020-11-07 01:17:52.632195] _LISTENER == ConnectionFrom(2a00:5881:4008:4210:7c38:4a33:c6a4:22b9, 45668) [Allowed]
[2020-11-07 01:17:52.632487] There are [0] clients from [2a00:5881:4008:4210:7c38:4a33:c6a4:22b9]
[2020-11-07 01:17:52.767556] (2a00:5881:4008:4210:7c38:4a33:c6a4:22b9) CLI -> ZNC [PASS password]
[2020-11-07 01:17:52.767725] (2a00:5881:4008:4210:7c38:4a33:c6a4:22b9) CLI -> ZNC [CAP LS 302]
[2020-11-07 01:17:52.767812] (2a00:5881:4008:4210:7c38:4a33:c6a4:22b9) ZNC -> CLI [:irc.znc.in CAP unknown-nick LS :batc
h cap-notify echo-message multi-prefix server-time userhost-in-names znc.in/batch znc.in/self-message znc.in/server-time
-iso]
[2020-11-07 01:17:52.768057] (2a00:5881:4008:4210:7c38:4a33:c6a4:22b9) CLI -> ZNC [NICK quentin]
[2020-11-07 01:17:52.768198] (2a00:5881:4008:4210:7c38:4a33:c6a4:22b9) CLI -> ZNC [USER caseof/geeknode 0 * :caseof/geek
node]
[2020-11-07 01:17:52.768780] (2a00:5881:4008:4210:7c38:4a33:c6a4:22b9) CLI -> ZNC [CAP REQ :cap-notify multi-prefix serv
er-time znc.in/server-time-iso znc.in/self-message]
[2020-11-07 01:17:52.768876] (2a00:5881:4008:4210:7c38:4a33:c6a4:22b9) ZNC -> CLI [@time=2020-11-07T00:17:52.768Z :irc.z
nc.in CAP quentin ACK :cap-notify multi-prefix server-time znc.in/server-time-iso znc.in/self-message]
[2020-11-07 01:17:52.769220] (2a00:5881:4008:4210:7c38:4a33:c6a4:22b9) CLI -> ZNC [CAP END]
[2020-11-07 01:17:52.769282] GetKey() returned status 20 with key 3207a6f22e0fde7c0781b8d0b78dfa15126595b7
[2020-11-07 01:17:52.769312] User: caseof Key:
[2020-11-07 01:17:52.769340] Peer got no public key, ignoring
```
<!-- github-sync-id:738113205 -->
20 X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY: unable to get local issuer certificate
the issuer certificate could not be found: this occurs if the issuer certificate of an untrusted certificate cannot be found.
That error is not one of those that is ignored by certauth in the code I linked above.
@CaseOf Could you print the subject and issuer of your certificate? I would guess that your certificate is not properly self-signed, because I would expect the error X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT. So, somehow your certificate does not count as self-signed...?
```
GetKey() returned status 20 with key 3207a6f22e0fde7c0781b8d0b78dfa15126595b7
```
The above comes from here:
https://github.com/znc/znc/blob/0af3c4b234b7839bb1162e74b01b66e1a05e6fa1/modules/certauth.cpp#L221-L237
where `GetKey` is here:
https://github.com/jimloco/Csocket/blob/e8d9e0bb248c521c2c7fa01e1c6a116d929c41b4/Csocket.cc#L2875-L2905
Okay, so `SSL_get_verify_result` returned 20. According to https://www.openssl.org/docs/man1.0.2/man1/verify.html, that's:
> 20 X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY: unable to get local issuer certificate
>the issuer certificate could not be found: this occurs if the issuer certificate of an untrusted certificate cannot be found.
That error is not one of those that is ignored by certauth in the code I linked above.
@CaseOf Could you print the subject and issuer of your certificate? I would guess that your certificate is not properly self-signed, because I would expect the error `X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT`. So, somehow your certificate does not count as self-signed...?
<!-- github-comment-id:723416505 -->
Okay, I have no clue where that X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY comes from. This looks "obviously self-signed". However, I wouldn't claim that I fully understand this stuff, so perhaps someone else has an idea...
(Did I perhaps look up the error incorrectly?)
```
Issuer: CN=Case_Of
Subject: CN=Case_Of
```
Okay, I have no clue where that `X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY` comes from. This looks "obviously self-signed". However, I wouldn't claim that I fully understand this stuff, so perhaps someone else has an idea...
(Did I perhaps look up the error incorrectly?)
<!-- github-comment-id:724132536 -->
Your certificate is a self-signed certificate. if the certificate is self-signed you will always get "Unable to get issuer cert locally" or similar invalids - this is the case with any Self Signed certificate.
There are cases this can be adjusted - internal Certificate Authority systems for instance will have the CA cert added to the system store and then added to the cert chain. However, your system will error hard on that if it's self-signed. Likely, LibreSSL is expecting a 'valid identity certificate' (which is unusual since OpenSSL doesn't have that problem). (Also, your key/cert lines are inverted - you need to have key and then cert I believe for the PEM to work anyways)
Your certificate is a self-signed certificate. if the certificate is self-signed you will *always* get "Unable to get issuer cert locally" or similar invalids - this is the case with any Self Signed certificate.
There are cases this can be adjusted - internal Certificate Authority systems for instance will have the CA cert added to the system store and then added to the cert chain. However, your system will error hard on that if it's self-signed. Likely, LibreSSL is expecting a 'valid identity certificate' (which is unusual since OpenSSL doesn't have that problem). (Also, your key/cert lines are inverted - you need to have key and then cert I believe for the PEM to work anyways)
<!-- github-comment-id:724136797 -->
if the certificate is self-signed you will always get "Unable to get issuer cert locally" or similar invalids
@teward In that case: How does certauth work for anyone? That module explicitly ignores the "usual" errors, so something must be different with this cert. If verification would fail with X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN or X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT or X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE, everything would be fine.
> if the certificate is self-signed you will always get "Unable to get issuer cert locally" or similar invalids
@teward In that case: How does certauth work for anyone? That module explicitly ignores the "usual" errors, so something must be different with this cert. If verification would fail with `X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN` or `X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT` or `X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE`, everything would be fine.
<!-- github-comment-id:724142263 -->
Unless the error codes aren't properly handled. However I think your key and cert are inverted in your PEM (most secret item comes first!) so I think you need to switch the order in your PEM file. Because I think it's seeing it just as a bare cert not a private identity cert.
This said, I'm OpenSSL fluent in this, not LibreSSL fluent - so my statements are just statements from the OpenSSL side of things.
Is it possible that LibreSSL is throwing an invalid status here? OpenSSL handles this properly ;)
Unless the error codes aren't properly handled. However I think your key and cert are inverted in your PEM (most secret item comes first!) so I think you need to switch the order in your PEM file. Because I think it's seeing it just as a bare cert not a private identity cert.
This said, I'm OpenSSL fluent in this, not LibreSSL fluent - so my statements are just statements from the OpenSSL side of things.
Is it possible that LibreSSL is throwing an invalid status here? OpenSSL handles this properly ;)
<!-- github-comment-id:724143405 -->
Hm. I tried to reproduce this using openssl s_client -cert /tmp/foo.pem -key /tmp/foo.pem -connect localhost:1234 and this works with the files that were provided above (current debian testing; only OpenSSL involved). (Yes, I had to type IRC commands to load certauth and have it add the certificate. I do not want to do this again. I miss backspace.)
(I just updated my system (there was an openssl update) and this still works.)
Hm. I tried to reproduce this using `openssl s_client -cert /tmp/foo.pem -key /tmp/foo.pem -connect localhost:1234` and this works with the files that were provided above (current debian testing; only OpenSSL involved). (Yes, I had to type IRC commands to load `certauth` and have it add the certificate. I do not want to do this again. I miss backspace.)
(I just updated my system (there was an openssl update) and this still works.)
<!-- github-comment-id:724148969 -->
Hm. I tried to reproduce this using openssl s_client ...
Yes, I tested as well. The problem I see here is that unlike Debian/Ubuntu and most systems which are OpenSSL driven, this bug specifically says LibreSSL is involved - which means that it is likely LibreSSL failing to process the certificate properly and returning the error; it's also possible this is Not A ZNC Problem technically if LibreSSL fails hard.
> Hm. I tried to reproduce this using `openssl s_client ...`
Yes, I tested as well. The problem I see here is that unlike Debian/Ubuntu and most systems which are OpenSSL driven, **this bug specifically says LibreSSL is involved** - which means that it is likely LibreSSL failing to process the certificate properly and returning the error; it's also possible this is Not A ZNC Problem technically if LibreSSL fails hard.
<!-- github-comment-id:724150902 -->
LibreSSL 3.2.2 has a new/replacement X.509 verifier that addresses a bunch of problems with the original OpenSSL based X.509 verifier. Unfortunately, there are loads of corner cases and particular API behaviour (much of it undocumented) that various pieces of software depend on. We'll take a look at this - I suspect we're returning X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY where the previous verifier was failing in a different way. Thanks for providing the relevant details/code snippets from the znc side.
LibreSSL 3.2.2 has a new/replacement X.509 verifier that addresses a bunch of problems with the original OpenSSL based X.509 verifier. Unfortunately, there are loads of corner cases and particular API behaviour (much of it undocumented) that various pieces of software depend on. We'll take a look at this - I suspect we're returning `X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY` where the previous verifier was failing in a different way. Thanks for providing the relevant details/code snippets from the znc side.
<!-- github-comment-id:724163233 -->
Yeah, sorry folks, the legacy validation API is pretty squirrelly, and some of the legacy errors actually don't make any sense when you actually chase down all possible chains. Nevertheless I have a candidate fix and we should be able to have this thing feeding you back the legacy "self signed" errors in the relevant special cases very soon. Thanks for the report.
Yeah, sorry folks, the legacy validation API is pretty squirrelly, and some of the legacy errors actually *don't make any sense* when you actually chase down all possible chains. Nevertheless I have a candidate fix and we should be able to have this thing feeding you back the legacy "self signed" errors in the relevant special cases very soon. Thanks for the report.
<!-- github-comment-id:725701953 -->
Of note -> "fail hard" is still fail. We still fail validation in this case, it's simply how you choose to interpret the error code (and yes I understand the awful legacy here that forces you to do that ;)
Of note -> "fail hard" is still fail. We still fail validation in this case, it's simply how you choose to interpret the error code (and yes I understand the awful legacy here that forces you to do that ;)
<!-- github-comment-id:725702426 -->
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Hello, it seems that on znc v1.8 certauth module is broken. It cant get certificate sent by clients.
This GetKey() function returns status 20.
Also, I’m using LibreSSL 3.2.2.
Built ZNC with it and generated certificate with it too.
I’m running on Gentoo for you to get the build environment.
I looked a little on sources and it comes from https://github.com/znc/znc/blob/6cd80535c064e91155468e79f50fc1c3f3c0f3e5/modules/certauth.cpp#L221
Some debug logs:
The above comes from here:
https://github.com/znc/znc/blob/0af3c4b234b7839bb1162e74b01b66e1a05e6fa1/modules/certauth.cpp#L221-L237
where
GetKeyis here:https://github.com/jimloco/Csocket/blob/e8d9e0bb248c521c2c7fa01e1c6a116d929c41b4/Csocket.cc#L2875-L2905
Okay, so
SSL_get_verify_resultreturned 20. According to https://www.openssl.org/docs/man1.0.2/man1/verify.html, that's:That error is not one of those that is ignored by certauth in the code I linked above.
@CaseOf Could you print the subject and issuer of your certificate? I would guess that your certificate is not properly self-signed, because I would expect the error
X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT. So, somehow your certificate does not count as self-signed...?Hi, here is the certificate I used (dont worry, it’s removed from my *certauth list now).
It’s in PEM format.
Else, from
opensslcommand:Okay, I have no clue where that
X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLYcomes from. This looks "obviously self-signed". However, I wouldn't claim that I fully understand this stuff, so perhaps someone else has an idea...(Did I perhaps look up the error incorrectly?)
Your certificate is a self-signed certificate. if the certificate is self-signed you will always get "Unable to get issuer cert locally" or similar invalids - this is the case with any Self Signed certificate.
There are cases this can be adjusted - internal Certificate Authority systems for instance will have the CA cert added to the system store and then added to the cert chain. However, your system will error hard on that if it's self-signed. Likely, LibreSSL is expecting a 'valid identity certificate' (which is unusual since OpenSSL doesn't have that problem). (Also, your key/cert lines are inverted - you need to have key and then cert I believe for the PEM to work anyways)
@teward In that case: How does certauth work for anyone? That module explicitly ignores the "usual" errors, so something must be different with this cert. If verification would fail with
X509_V_ERR_SELF_SIGNED_CERT_IN_CHAINorX509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERTorX509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE, everything would be fine.Unless the error codes aren't properly handled. However I think your key and cert are inverted in your PEM (most secret item comes first!) so I think you need to switch the order in your PEM file. Because I think it's seeing it just as a bare cert not a private identity cert.
This said, I'm OpenSSL fluent in this, not LibreSSL fluent - so my statements are just statements from the OpenSSL side of things.
Is it possible that LibreSSL is throwing an invalid status here? OpenSSL handles this properly ;)
Hm. I tried to reproduce this using
openssl s_client -cert /tmp/foo.pem -key /tmp/foo.pem -connect localhost:1234and this works with the files that were provided above (current debian testing; only OpenSSL involved). (Yes, I had to type IRC commands to loadcertauthand have it add the certificate. I do not want to do this again. I miss backspace.)(I just updated my system (there was an openssl update) and this still works.)
Yes, I tested as well. The problem I see here is that unlike Debian/Ubuntu and most systems which are OpenSSL driven, this bug specifically says LibreSSL is involved - which means that it is likely LibreSSL failing to process the certificate properly and returning the error; it's also possible this is Not A ZNC Problem technically if LibreSSL fails hard.
LibreSSL 3.2.2 has a new/replacement X.509 verifier that addresses a bunch of problems with the original OpenSSL based X.509 verifier. Unfortunately, there are loads of corner cases and particular API behaviour (much of it undocumented) that various pieces of software depend on. We'll take a look at this - I suspect we're returning
X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLYwhere the previous verifier was failing in a different way. Thanks for providing the relevant details/code snippets from the znc side.Yeah, sorry folks, the legacy validation API is pretty squirrelly, and some of the legacy errors actually don't make any sense when you actually chase down all possible chains. Nevertheless I have a candidate fix and we should be able to have this thing feeding you back the legacy "self signed" errors in the relevant special cases very soon. Thanks for the report.
Of note -> "fail hard" is still fail. We still fail validation in this case, it's simply how you choose to interpret the error code (and yes I understand the awful legacy here that forces you to do that ;)