[OCSP Stapling] Cached bad response of Server-Side OCSP stabling in .NET7 Linux  #89907

Description

@cdlliuy

Description

In .NET7 Linux, we noticed that the Server Side OCSP Stapling is enabled by default, in which the response from OCSP responder is cached to speed up the cert status check

However, if OCSP responder send back a wrong response ...it will be cached as well in TLS server side. Then ,the client of TLS server will always receive the bad extension.status_request , then failed to setup the SSL connection due to parse failure.

From .NET runtime code, I can see the logic to do OCSP downloading , then cache for about 1 day if the response content is not null
https://github.com/dotnet/runtime/blob/main/src/libraries/System.Net.Security/src/System/Net/Security/SslStreamCertificateContext.Linux.cs#L226C1-L249
Then, inside the download code, I can see the bad http status code is not handled.
https://github.com/dotnet/runtime/blob/main/src/libraries/Common/src/System/Net/Http/X509ResourceClient.cs#L182C24-L243

What happens in our TLS server is, it tries to connection a OCSP website, and it should get a 5xx response. The OCSP website configures "an error html page" when it fails, so the response content is not empty, and our TLS server cached the error html page as the OCSP response.

Then, when client side made a https connection to our TLS server, from the ssl debug info, we can see the error html page inside the handshake payload .. It said "Our services aren't available right now

We're working to restore all services as soon as possible. Please check back soon"

08F0: CE 3C 21 44 4F 43 54 59 50 45 20 68 74 6D 6C 20 .<!DOCTYPE html 0900: 50 55 42 4C 49 43 20 27 2D 2F 2F 57 33 43 2F 2F PUBLIC '-//W3C//
0910: 44 54 44 20 58 48 54 4D 4C 20 31 2E 30 20 54 72 DTD XHTML 1.0 Tr
0920: 61 6E 73 69 74 69 6F 6E 61 6C 2F 2F 45 4E 27 20 ansitional//EN' 0930: 27 68 74 74 70 3A 2F 2F 77 77 77 2E 77 33 2E 6F 'http://www.w3.o
0940: 72 67 2F 54 52 2F 78 68 74 6D 6C 31 2F 44 54 44 rg/TR/xhtml1/DTD
0950: 2F 78 68 74 6D 6C 31 2D 74 72 61 6E 73 69 74 69 /xhtml1-transiti
0960: 6F 6E 61 6C 2E 64 74 64 27 3E 3C 68 74 6D 6C 20 onal.dtd'><html 0970: 78 6D 6C 6E 73 3D 27 68 74 74 70 3A 2F 2F 77 77 xmlns='http://ww
0980: 77 2E 77 33 2E 6F 72 67 2F 31 39 39 39 2F 78 68 w.w3.org/1999/xh
0990: 74 6D 6C 27 3E 3C 68 65 61 64 3E 3C 6D 65 74 61 tml'><head><meta
09A0: 20 63 6F 6E 74 65 6E 74 3D 27 74 65 78 74 2F 68 content='text/h
09B0: 74 6D 6C 3B 20 63 68 61 72 73 65 74 3D 75 74 66 tml; charset=utf
09C0: 2D 38 27 20 68 74 74 70 2D 65 71 75 69 76 3D 27 -8' http-equiv='
09D0: 63 6F 6E 74 65 6E 74 2D 74 79 70 65 27 2F 3E 3C content-type'/><
09E0: 73 74 79 6C 65 20 74 79 70 65 3D 27 74 65 78 74 style type='text
09F0: 2F 63 73 73 27 3E 62 6F 64 79 20 7B 66 6F 6E 74 /css'>body .font
0A00: 2D 66 61 6D 69 6C 79 3A 41 72 69 61 6C 3B 20 6D -family:Arial; m
0A10: 61 72 67 69 6E 2D 6C 65 66 74 3A 34 30 70 78 3B argin-left:40px;
0A20: 20 7D 69 6D 67 20 20 7B 20 62 6F 72 64 65 72 3A .img . border:
0A30: 30 20 6E 6F 6E 65 3B 20 7D 23 63 6F 6E 74 65 6E 0 none; .#conten
0A40: 74 20 7B 20 6D 61 72 67 69 6E 2D 6C 65 66 74 3A t . margin-left:
0A50: 20 61 75 74 6F 3B 20 6D 61 72 67 69 6E 2D 72 69 auto; margin-ri
0A60: 67 68 74 3A 20 61 75 74 6F 20 7D 23 6D 65 73 73 ght: auto .#mess
0A70: 61 67 65 20 68 32 20 7B 20 66 6F 6E 74 2D 73 69 age h2 . font-si
0A80: 7A 65 3A 20 32 30 70 78 3B 20 66 6F 6E 74 2D 77 ze: 20px; font-w
0A90: 65 69 67 68 74 3A 20 6E 6F 72 6D 61 6C 3B 20 63 eight: normal; c
0AA0: 6F 6C 6F 72 3A 20 23 30 30 30 30 30 30 3B 20 6D olor: #000000; m
0AB0: 61 72 67 69 6E 3A 20 33 34 70 78 20 30 70 78 20 argin: 34px 0px 0AC0: 30 70 78 20 30 70 78 20 7D 23 6D 65 73 73 61 67 0px 0px .#messag
0AD0: 65 20 70 20 20 7B 20 66 6F 6E 74 2D 73 69 7A 65 e p . font-size
0AE0: 3A 20 31 33 70 78 3B 20 63 6F 6C 6F 72 3A 20 23 : 13px; color: #
0AF0: 30 30 30 30 30 30 3B 20 6D 61 72 67 69 6E 3A 20 000000; margin: 0B00: 37 70 78 20 30 70 78 20 30 70 78 30 70 78 7D 23 7px 0px 0px0px.#
0B10: 65 72 72 6F 72 72 65 66 20 7B 20 66 6F 6E 74 2D errorref . font-
0B20: 73 69 7A 65 3A 20 31 31 70 78 3B 20 63 6F 6C 6F size: 11px; colo
0B30: 72 3A 20 23 37 33 37 33 37 33 3B 20 6D 61 72 67 r: #737373; marg
0B40: 69 6E 2D 74 6F 70 3A 20 34 31 70 78 20 7D 3C 2F in-top: 41px .</
0B50: 73 74 79 6C 65 3E 3C 74 69 74 6C 65 3E 43 45 53 style><title>CES
0B60: 50 4B 49 3C 2F 74 69 74 6C 65 3E 3C 2F 68 65 61 PKI</title></hea
0B70: 64 3E 3C 62 6F 64 79 3E 3C 64 69 76 20 69 64 3D d><body><div id=
0B80: 27 63 6F 6E 74 65 6E 74 27 3E 3C 64 69 76 20 69 'content'><div i
0B90: 64 3D 27 6D 65 73 73 61 67 65 27 3E 3C 68 32 3E d='message'><h2>
0BA0: 4F 75 72 20 73 65 72 76 69 63 65 73 20 61 72 65 Our services are
0BB0: 6E 27 74 20 61 76 61 69 6C 61 62 6C 65 20 72 69 n't available ri
0BC0: 67 68 74 20 6E 6F 77 3C 2F 68 32 3E 3C 70 3E 57 ght now</h2><p>W
0BD0: 65 27 72 65 20 77 6F 72 6B 69 6E 67 20 74 6F 20 e're working to 0BE0: 72 65 73 74 6F 72 65 20 61 6C 6C 20 73 65 72 76 restore all serv
0BF0: 69 63 65 73 20 61 73 20 73 6F 6F 6E 20 61 73 20 ices as soon as 0C00: 70 6F 73 73 69 62 6C 65 2E 20 50 6C 65 61 73 65 possible. Please
0C10: 20 63 68 65 63 6B 20 62 61 63 6B 20 73 6F 6F 6E check back soon
0C20: 2E 3C 2F 70 3E 3C 2F 64 69 76 3E 3C 64 69 76 20 .</p></div><div 0C30: 69 64 3D 27 65 72 72 6F 72 72 65 66 27 3E 3C 73 id='errorref'><s
0C40: 70 61 6E 3E 52 65 66 20 41 3A 20 34 33 30 46 37 pan>Ref A: 430F7
0C50: 35 37 35 34 30 35 44 34 30 36 32 38 32 45 36 44 575405D406282E6D
0C60: 38 41 31 32 38 33 42 43 45 35 44 20 52 65 66 20 8A1283BCE5D Ref 0C70: 42 3A 20 43 48 31 41 41 32 30 34 30 39 30 34 30 B: CH1AA20409040
0C80: 32 35 20 52 65 66 20 43 3A 20 32 30 32 33 2D 30 25 Ref C: 2023-0
0C90: 37 2D 32 35 54 31 38 3A 34 35 3A 32 31 5A 3C 2F 7-25T18:45:21Z</
0CA0: 73 70 61 6E 3E 3C 2F 64 69 76 3E 3C 2F 64 69 76 span></div></div
0CB0: 3E 3C 2F 62 6F 64 79 3E 3C 2F 68 74 6D 6C 3E 00 ></body></html>.

Then with decrypted, client side saw

 "extensions": {
"status_request (5)": {
extra data at the end
}
}

and failed with

 Caused by: java.io.IOException: extra data at the end
at java.base/sun.security.util.DerValue.<init>(DerValue.java:428)

The issue can be resolved when we restarted our TLS server which will get a refresh ocsp response.

However, I wonder whether it is possible to check the status code of ocsp response, and avoid the caching when the response is not correct?

Reproduction Steps

intermittent issue due to ocsp responder availablity.
maybe setup a bad ocsp responder can reproduce it stably.

Expected behavior

expect the retry on ocsp download or avoid cache the ocsp bad result

Actual behavior

the bad ocsp response is cached.

Regression?

No response

Known Workarounds

restart TLS server to fetch a new OCSP response

Configuration

.NET7 Kershel webserver on Linux

Other information

No response

Drafted a possible fix #89908 for this issue. Please help to review

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    , 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
     blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
    }
    } catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
    })();
    (function(){
    try {
    var __m = "github.com";
    var __re = new RegExp('^' + "github\\.com" + '
    
    Skip to content

    [OCSP Stapling] Cached bad response of Server-Side OCSP stabling in .NET7 Linux  #89907

    Description

    @cdlliuy

    Description

    In .NET7 Linux, we noticed that the Server Side OCSP Stapling is enabled by default, in which the response from OCSP responder is cached to speed up the cert status check

    However, if OCSP responder send back a wrong response ...it will be cached as well in TLS server side. Then ,the client of TLS server will always receive the bad extension.status_request , then failed to setup the SSL connection due to parse failure.

    From .NET runtime code, I can see the logic to do OCSP downloading , then cache for about 1 day if the response content is not null
    https://github.com/dotnet/runtime/blob/main/src/libraries/System.Net.Security/src/System/Net/Security/SslStreamCertificateContext.Linux.cs#L226C1-L249
    Then, inside the download code, I can see the bad http status code is not handled.
    https://github.com/dotnet/runtime/blob/main/src/libraries/Common/src/System/Net/Http/X509ResourceClient.cs#L182C24-L243

    What happens in our TLS server is, it tries to connection a OCSP website, and it should get a 5xx response. The OCSP website configures "an error html page" when it fails, so the response content is not empty, and our TLS server cached the error html page as the OCSP response.

    Then, when client side made a https connection to our TLS server, from the ssl debug info, we can see the error html page inside the handshake payload .. It said "Our services aren't available right now

    We're working to restore all services as soon as possible. Please check back soon"

    08F0: CE 3C 21 44 4F 43 54 59 50 45 20 68 74 6D 6C 20 .<!DOCTYPE html 0900: 50 55 42 4C 49 43 20 27 2D 2F 2F 57 33 43 2F 2F PUBLIC '-//W3C//
    0910: 44 54 44 20 58 48 54 4D 4C 20 31 2E 30 20 54 72 DTD XHTML 1.0 Tr
    0920: 61 6E 73 69 74 69 6F 6E 61 6C 2F 2F 45 4E 27 20 ansitional//EN' 0930: 27 68 74 74 70 3A 2F 2F 77 77 77 2E 77 33 2E 6F 'http://www.w3.o
    0940: 72 67 2F 54 52 2F 78 68 74 6D 6C 31 2F 44 54 44 rg/TR/xhtml1/DTD
    0950: 2F 78 68 74 6D 6C 31 2D 74 72 61 6E 73 69 74 69 /xhtml1-transiti
    0960: 6F 6E 61 6C 2E 64 74 64 27 3E 3C 68 74 6D 6C 20 onal.dtd'><html 0970: 78 6D 6C 6E 73 3D 27 68 74 74 70 3A 2F 2F 77 77 xmlns='http://ww
    0980: 77 2E 77 33 2E 6F 72 67 2F 31 39 39 39 2F 78 68 w.w3.org/1999/xh
    0990: 74 6D 6C 27 3E 3C 68 65 61 64 3E 3C 6D 65 74 61 tml'><head><meta
    09A0: 20 63 6F 6E 74 65 6E 74 3D 27 74 65 78 74 2F 68 content='text/h
    09B0: 74 6D 6C 3B 20 63 68 61 72 73 65 74 3D 75 74 66 tml; charset=utf
    09C0: 2D 38 27 20 68 74 74 70 2D 65 71 75 69 76 3D 27 -8' http-equiv='
    09D0: 63 6F 6E 74 65 6E 74 2D 74 79 70 65 27 2F 3E 3C content-type'/><
    09E0: 73 74 79 6C 65 20 74 79 70 65 3D 27 74 65 78 74 style type='text
    09F0: 2F 63 73 73 27 3E 62 6F 64 79 20 7B 66 6F 6E 74 /css'>body .font
    0A00: 2D 66 61 6D 69 6C 79 3A 41 72 69 61 6C 3B 20 6D -family:Arial; m
    0A10: 61 72 67 69 6E 2D 6C 65 66 74 3A 34 30 70 78 3B argin-left:40px;
    0A20: 20 7D 69 6D 67 20 20 7B 20 62 6F 72 64 65 72 3A .img . border:
    0A30: 30 20 6E 6F 6E 65 3B 20 7D 23 63 6F 6E 74 65 6E 0 none; .#conten
    0A40: 74 20 7B 20 6D 61 72 67 69 6E 2D 6C 65 66 74 3A t . margin-left:
    0A50: 20 61 75 74 6F 3B 20 6D 61 72 67 69 6E 2D 72 69 auto; margin-ri
    0A60: 67 68 74 3A 20 61 75 74 6F 20 7D 23 6D 65 73 73 ght: auto .#mess
    0A70: 61 67 65 20 68 32 20 7B 20 66 6F 6E 74 2D 73 69 age h2 . font-si
    0A80: 7A 65 3A 20 32 30 70 78 3B 20 66 6F 6E 74 2D 77 ze: 20px; font-w
    0A90: 65 69 67 68 74 3A 20 6E 6F 72 6D 61 6C 3B 20 63 eight: normal; c
    0AA0: 6F 6C 6F 72 3A 20 23 30 30 30 30 30 30 3B 20 6D olor: #000000; m
    0AB0: 61 72 67 69 6E 3A 20 33 34 70 78 20 30 70 78 20 argin: 34px 0px 0AC0: 30 70 78 20 30 70 78 20 7D 23 6D 65 73 73 61 67 0px 0px .#messag
    0AD0: 65 20 70 20 20 7B 20 66 6F 6E 74 2D 73 69 7A 65 e p . font-size
    0AE0: 3A 20 31 33 70 78 3B 20 63 6F 6C 6F 72 3A 20 23 : 13px; color: #
    0AF0: 30 30 30 30 30 30 3B 20 6D 61 72 67 69 6E 3A 20 000000; margin: 0B00: 37 70 78 20 30 70 78 20 30 70 78 30 70 78 7D 23 7px 0px 0px0px.#
    0B10: 65 72 72 6F 72 72 65 66 20 7B 20 66 6F 6E 74 2D errorref . font-
    0B20: 73 69 7A 65 3A 20 31 31 70 78 3B 20 63 6F 6C 6F size: 11px; colo
    0B30: 72 3A 20 23 37 33 37 33 37 33 3B 20 6D 61 72 67 r: #737373; marg
    0B40: 69 6E 2D 74 6F 70 3A 20 34 31 70 78 20 7D 3C 2F in-top: 41px .</
    0B50: 73 74 79 6C 65 3E 3C 74 69 74 6C 65 3E 43 45 53 style><title>CES
    0B60: 50 4B 49 3C 2F 74 69 74 6C 65 3E 3C 2F 68 65 61 PKI</title></hea
    0B70: 64 3E 3C 62 6F 64 79 3E 3C 64 69 76 20 69 64 3D d><body><div id=
    0B80: 27 63 6F 6E 74 65 6E 74 27 3E 3C 64 69 76 20 69 'content'><div i
    0B90: 64 3D 27 6D 65 73 73 61 67 65 27 3E 3C 68 32 3E d='message'><h2>
    0BA0: 4F 75 72 20 73 65 72 76 69 63 65 73 20 61 72 65 Our services are
    0BB0: 6E 27 74 20 61 76 61 69 6C 61 62 6C 65 20 72 69 n't available ri
    0BC0: 67 68 74 20 6E 6F 77 3C 2F 68 32 3E 3C 70 3E 57 ght now</h2><p>W
    0BD0: 65 27 72 65 20 77 6F 72 6B 69 6E 67 20 74 6F 20 e're working to 0BE0: 72 65 73 74 6F 72 65 20 61 6C 6C 20 73 65 72 76 restore all serv
    0BF0: 69 63 65 73 20 61 73 20 73 6F 6F 6E 20 61 73 20 ices as soon as 0C00: 70 6F 73 73 69 62 6C 65 2E 20 50 6C 65 61 73 65 possible. Please
    0C10: 20 63 68 65 63 6B 20 62 61 63 6B 20 73 6F 6F 6E check back soon
    0C20: 2E 3C 2F 70 3E 3C 2F 64 69 76 3E 3C 64 69 76 20 .</p></div><div 0C30: 69 64 3D 27 65 72 72 6F 72 72 65 66 27 3E 3C 73 id='errorref'><s
    0C40: 70 61 6E 3E 52 65 66 20 41 3A 20 34 33 30 46 37 pan>Ref A: 430F7
    0C50: 35 37 35 34 30 35 44 34 30 36 32 38 32 45 36 44 575405D406282E6D
    0C60: 38 41 31 32 38 33 42 43 45 35 44 20 52 65 66 20 8A1283BCE5D Ref 0C70: 42 3A 20 43 48 31 41 41 32 30 34 30 39 30 34 30 B: CH1AA20409040
    0C80: 32 35 20 52 65 66 20 43 3A 20 32 30 32 33 2D 30 25 Ref C: 2023-0
    0C90: 37 2D 32 35 54 31 38 3A 34 35 3A 32 31 5A 3C 2F 7-25T18:45:21Z</
    0CA0: 73 70 61 6E 3E 3C 2F 64 69 76 3E 3C 2F 64 69 76 span></div></div
    0CB0: 3E 3C 2F 62 6F 64 79 3E 3C 2F 68 74 6D 6C 3E 00 ></body></html>.
    

    Then with decrypted, client side saw

     "extensions": {
    "status_request (5)": {
    extra data at the end
    }
    }
    

    and failed with

     Caused by: java.io.IOException: extra data at the end
    at java.base/sun.security.util.DerValue.<init>(DerValue.java:428)
    

    The issue can be resolved when we restarted our TLS server which will get a refresh ocsp response.

    However, I wonder whether it is possible to check the status code of ocsp response, and avoid the caching when the response is not correct?

    Reproduction Steps

    intermittent issue due to ocsp responder availablity.
    maybe setup a bad ocsp responder can reproduce it stably.

    Expected behavior

    expect the retry on ocsp download or avoid cache the ocsp bad result

    Actual behavior

    the bad ocsp response is cached.

    Regression?

    No response

    Known Workarounds

    restart TLS server to fetch a new OCSP response

    Configuration

    .NET7 Kershel webserver on Linux

    Other information

    No response

    Drafted a possible fix #89908 for this issue. Please help to review

    Activity

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      , 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
      Skip to content

      [OCSP Stapling] Cached bad response of Server-Side OCSP stabling in .NET7 Linux  #89907

      Description

      @cdlliuy

      Description

      In .NET7 Linux, we noticed that the Server Side OCSP Stapling is enabled by default, in which the response from OCSP responder is cached to speed up the cert status check

      However, if OCSP responder send back a wrong response ...it will be cached as well in TLS server side. Then ,the client of TLS server will always receive the bad extension.status_request , then failed to setup the SSL connection due to parse failure.

      From .NET runtime code, I can see the logic to do OCSP downloading , then cache for about 1 day if the response content is not null
      https://github.com/dotnet/runtime/blob/main/src/libraries/System.Net.Security/src/System/Net/Security/SslStreamCertificateContext.Linux.cs#L226C1-L249
      Then, inside the download code, I can see the bad http status code is not handled.
      https://github.com/dotnet/runtime/blob/main/src/libraries/Common/src/System/Net/Http/X509ResourceClient.cs#L182C24-L243

      What happens in our TLS server is, it tries to connection a OCSP website, and it should get a 5xx response. The OCSP website configures "an error html page" when it fails, so the response content is not empty, and our TLS server cached the error html page as the OCSP response.

      Then, when client side made a https connection to our TLS server, from the ssl debug info, we can see the error html page inside the handshake payload .. It said "Our services aren't available right now

      We're working to restore all services as soon as possible. Please check back soon"

      08F0: CE 3C 21 44 4F 43 54 59 50 45 20 68 74 6D 6C 20 .<!DOCTYPE html 0900: 50 55 42 4C 49 43 20 27 2D 2F 2F 57 33 43 2F 2F PUBLIC '-//W3C//
      0910: 44 54 44 20 58 48 54 4D 4C 20 31 2E 30 20 54 72 DTD XHTML 1.0 Tr
      0920: 61 6E 73 69 74 69 6F 6E 61 6C 2F 2F 45 4E 27 20 ansitional//EN' 0930: 27 68 74 74 70 3A 2F 2F 77 77 77 2E 77 33 2E 6F 'http://www.w3.o
      0940: 72 67 2F 54 52 2F 78 68 74 6D 6C 31 2F 44 54 44 rg/TR/xhtml1/DTD
      0950: 2F 78 68 74 6D 6C 31 2D 74 72 61 6E 73 69 74 69 /xhtml1-transiti
      0960: 6F 6E 61 6C 2E 64 74 64 27 3E 3C 68 74 6D 6C 20 onal.dtd'><html 0970: 78 6D 6C 6E 73 3D 27 68 74 74 70 3A 2F 2F 77 77 xmlns='http://ww
      0980: 77 2E 77 33 2E 6F 72 67 2F 31 39 39 39 2F 78 68 w.w3.org/1999/xh
      0990: 74 6D 6C 27 3E 3C 68 65 61 64 3E 3C 6D 65 74 61 tml'><head><meta
      09A0: 20 63 6F 6E 74 65 6E 74 3D 27 74 65 78 74 2F 68 content='text/h
      09B0: 74 6D 6C 3B 20 63 68 61 72 73 65 74 3D 75 74 66 tml; charset=utf
      09C0: 2D 38 27 20 68 74 74 70 2D 65 71 75 69 76 3D 27 -8' http-equiv='
      09D0: 63 6F 6E 74 65 6E 74 2D 74 79 70 65 27 2F 3E 3C content-type'/><
      09E0: 73 74 79 6C 65 20 74 79 70 65 3D 27 74 65 78 74 style type='text
      09F0: 2F 63 73 73 27 3E 62 6F 64 79 20 7B 66 6F 6E 74 /css'>body .font
      0A00: 2D 66 61 6D 69 6C 79 3A 41 72 69 61 6C 3B 20 6D -family:Arial; m
      0A10: 61 72 67 69 6E 2D 6C 65 66 74 3A 34 30 70 78 3B argin-left:40px;
      0A20: 20 7D 69 6D 67 20 20 7B 20 62 6F 72 64 65 72 3A .img . border:
      0A30: 30 20 6E 6F 6E 65 3B 20 7D 23 63 6F 6E 74 65 6E 0 none; .#conten
      0A40: 74 20 7B 20 6D 61 72 67 69 6E 2D 6C 65 66 74 3A t . margin-left:
      0A50: 20 61 75 74 6F 3B 20 6D 61 72 67 69 6E 2D 72 69 auto; margin-ri
      0A60: 67 68 74 3A 20 61 75 74 6F 20 7D 23 6D 65 73 73 ght: auto .#mess
      0A70: 61 67 65 20 68 32 20 7B 20 66 6F 6E 74 2D 73 69 age h2 . font-si
      0A80: 7A 65 3A 20 32 30 70 78 3B 20 66 6F 6E 74 2D 77 ze: 20px; font-w
      0A90: 65 69 67 68 74 3A 20 6E 6F 72 6D 61 6C 3B 20 63 eight: normal; c
      0AA0: 6F 6C 6F 72 3A 20 23 30 30 30 30 30 30 3B 20 6D olor: #000000; m
      0AB0: 61 72 67 69 6E 3A 20 33 34 70 78 20 30 70 78 20 argin: 34px 0px 0AC0: 30 70 78 20 30 70 78 20 7D 23 6D 65 73 73 61 67 0px 0px .#messag
      0AD0: 65 20 70 20 20 7B 20 66 6F 6E 74 2D 73 69 7A 65 e p . font-size
      0AE0: 3A 20 31 33 70 78 3B 20 63 6F 6C 6F 72 3A 20 23 : 13px; color: #
      0AF0: 30 30 30 30 30 30 3B 20 6D 61 72 67 69 6E 3A 20 000000; margin: 0B00: 37 70 78 20 30 70 78 20 30 70 78 30 70 78 7D 23 7px 0px 0px0px.#
      0B10: 65 72 72 6F 72 72 65 66 20 7B 20 66 6F 6E 74 2D errorref . font-
      0B20: 73 69 7A 65 3A 20 31 31 70 78 3B 20 63 6F 6C 6F size: 11px; colo
      0B30: 72 3A 20 23 37 33 37 33 37 33 3B 20 6D 61 72 67 r: #737373; marg
      0B40: 69 6E 2D 74 6F 70 3A 20 34 31 70 78 20 7D 3C 2F in-top: 41px .</
      0B50: 73 74 79 6C 65 3E 3C 74 69 74 6C 65 3E 43 45 53 style><title>CES
      0B60: 50 4B 49 3C 2F 74 69 74 6C 65 3E 3C 2F 68 65 61 PKI</title></hea
      0B70: 64 3E 3C 62 6F 64 79 3E 3C 64 69 76 20 69 64 3D d><body><div id=
      0B80: 27 63 6F 6E 74 65 6E 74 27 3E 3C 64 69 76 20 69 'content'><div i
      0B90: 64 3D 27 6D 65 73 73 61 67 65 27 3E 3C 68 32 3E d='message'><h2>
      0BA0: 4F 75 72 20 73 65 72 76 69 63 65 73 20 61 72 65 Our services are
      0BB0: 6E 27 74 20 61 76 61 69 6C 61 62 6C 65 20 72 69 n't available ri
      0BC0: 67 68 74 20 6E 6F 77 3C 2F 68 32 3E 3C 70 3E 57 ght now</h2><p>W
      0BD0: 65 27 72 65 20 77 6F 72 6B 69 6E 67 20 74 6F 20 e're working to 0BE0: 72 65 73 74 6F 72 65 20 61 6C 6C 20 73 65 72 76 restore all serv
      0BF0: 69 63 65 73 20 61 73 20 73 6F 6F 6E 20 61 73 20 ices as soon as 0C00: 70 6F 73 73 69 62 6C 65 2E 20 50 6C 65 61 73 65 possible. Please
      0C10: 20 63 68 65 63 6B 20 62 61 63 6B 20 73 6F 6F 6E check back soon
      0C20: 2E 3C 2F 70 3E 3C 2F 64 69 76 3E 3C 64 69 76 20 .</p></div><div 0C30: 69 64 3D 27 65 72 72 6F 72 72 65 66 27 3E 3C 73 id='errorref'><s
      0C40: 70 61 6E 3E 52 65 66 20 41 3A 20 34 33 30 46 37 pan>Ref A: 430F7
      0C50: 35 37 35 34 30 35 44 34 30 36 32 38 32 45 36 44 575405D406282E6D
      0C60: 38 41 31 32 38 33 42 43 45 35 44 20 52 65 66 20 8A1283BCE5D Ref 0C70: 42 3A 20 43 48 31 41 41 32 30 34 30 39 30 34 30 B: CH1AA20409040
      0C80: 32 35 20 52 65 66 20 43 3A 20 32 30 32 33 2D 30 25 Ref C: 2023-0
      0C90: 37 2D 32 35 54 31 38 3A 34 35 3A 32 31 5A 3C 2F 7-25T18:45:21Z</
      0CA0: 73 70 61 6E 3E 3C 2F 64 69 76 3E 3C 2F 64 69 76 span></div></div
      0CB0: 3E 3C 2F 62 6F 64 79 3E 3C 2F 68 74 6D 6C 3E 00 ></body></html>.
      

      Then with decrypted, client side saw

       "extensions": {
      "status_request (5)": {
      extra data at the end
      }
      }
      

      and failed with

       Caused by: java.io.IOException: extra data at the end
      at java.base/sun.security.util.DerValue.<init>(DerValue.java:428)
      

      The issue can be resolved when we restarted our TLS server which will get a refresh ocsp response.

      However, I wonder whether it is possible to check the status code of ocsp response, and avoid the caching when the response is not correct?

      Reproduction Steps

      intermittent issue due to ocsp responder availablity.
      maybe setup a bad ocsp responder can reproduce it stably.

      Expected behavior

      expect the retry on ocsp download or avoid cache the ocsp bad result

      Actual behavior

      the bad ocsp response is cached.

      Regression?

      No response

      Known Workarounds

      restart TLS server to fetch a new OCSP response

      Configuration

      .NET7 Kershel webserver on Linux

      Other information

      No response

      Drafted a possible fix #89908 for this issue. Please help to review

      Activity

      Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

      Metadata

      Metadata

      Assignees

      Type

      No type

      Projects

      No projects

        Milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions

        , 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
        Skip to content

        [OCSP Stapling] Cached bad response of Server-Side OCSP stabling in .NET7 Linux  #89907

        Description

        @cdlliuy

        Description

        In .NET7 Linux, we noticed that the Server Side OCSP Stapling is enabled by default, in which the response from OCSP responder is cached to speed up the cert status check

        However, if OCSP responder send back a wrong response ...it will be cached as well in TLS server side. Then ,the client of TLS server will always receive the bad extension.status_request , then failed to setup the SSL connection due to parse failure.

        From .NET runtime code, I can see the logic to do OCSP downloading , then cache for about 1 day if the response content is not null
        https://github.com/dotnet/runtime/blob/main/src/libraries/System.Net.Security/src/System/Net/Security/SslStreamCertificateContext.Linux.cs#L226C1-L249
        Then, inside the download code, I can see the bad http status code is not handled.
        https://github.com/dotnet/runtime/blob/main/src/libraries/Common/src/System/Net/Http/X509ResourceClient.cs#L182C24-L243

        What happens in our TLS server is, it tries to connection a OCSP website, and it should get a 5xx response. The OCSP website configures "an error html page" when it fails, so the response content is not empty, and our TLS server cached the error html page as the OCSP response.

        Then, when client side made a https connection to our TLS server, from the ssl debug info, we can see the error html page inside the handshake payload .. It said "Our services aren't available right now

        We're working to restore all services as soon as possible. Please check back soon"

        08F0: CE 3C 21 44 4F 43 54 59 50 45 20 68 74 6D 6C 20 .<!DOCTYPE html 0900: 50 55 42 4C 49 43 20 27 2D 2F 2F 57 33 43 2F 2F PUBLIC '-//W3C//
        0910: 44 54 44 20 58 48 54 4D 4C 20 31 2E 30 20 54 72 DTD XHTML 1.0 Tr
        0920: 61 6E 73 69 74 69 6F 6E 61 6C 2F 2F 45 4E 27 20 ansitional//EN' 0930: 27 68 74 74 70 3A 2F 2F 77 77 77 2E 77 33 2E 6F 'http://www.w3.o
        0940: 72 67 2F 54 52 2F 78 68 74 6D 6C 31 2F 44 54 44 rg/TR/xhtml1/DTD
        0950: 2F 78 68 74 6D 6C 31 2D 74 72 61 6E 73 69 74 69 /xhtml1-transiti
        0960: 6F 6E 61 6C 2E 64 74 64 27 3E 3C 68 74 6D 6C 20 onal.dtd'><html 0970: 78 6D 6C 6E 73 3D 27 68 74 74 70 3A 2F 2F 77 77 xmlns='http://ww
        0980: 77 2E 77 33 2E 6F 72 67 2F 31 39 39 39 2F 78 68 w.w3.org/1999/xh
        0990: 74 6D 6C 27 3E 3C 68 65 61 64 3E 3C 6D 65 74 61 tml'><head><meta
        09A0: 20 63 6F 6E 74 65 6E 74 3D 27 74 65 78 74 2F 68 content='text/h
        09B0: 74 6D 6C 3B 20 63 68 61 72 73 65 74 3D 75 74 66 tml; charset=utf
        09C0: 2D 38 27 20 68 74 74 70 2D 65 71 75 69 76 3D 27 -8' http-equiv='
        09D0: 63 6F 6E 74 65 6E 74 2D 74 79 70 65 27 2F 3E 3C content-type'/><
        09E0: 73 74 79 6C 65 20 74 79 70 65 3D 27 74 65 78 74 style type='text
        09F0: 2F 63 73 73 27 3E 62 6F 64 79 20 7B 66 6F 6E 74 /css'>body .font
        0A00: 2D 66 61 6D 69 6C 79 3A 41 72 69 61 6C 3B 20 6D -family:Arial; m
        0A10: 61 72 67 69 6E 2D 6C 65 66 74 3A 34 30 70 78 3B argin-left:40px;
        0A20: 20 7D 69 6D 67 20 20 7B 20 62 6F 72 64 65 72 3A .img . border:
        0A30: 30 20 6E 6F 6E 65 3B 20 7D 23 63 6F 6E 74 65 6E 0 none; .#conten
        0A40: 74 20 7B 20 6D 61 72 67 69 6E 2D 6C 65 66 74 3A t . margin-left:
        0A50: 20 61 75 74 6F 3B 20 6D 61 72 67 69 6E 2D 72 69 auto; margin-ri
        0A60: 67 68 74 3A 20 61 75 74 6F 20 7D 23 6D 65 73 73 ght: auto .#mess
        0A70: 61 67 65 20 68 32 20 7B 20 66 6F 6E 74 2D 73 69 age h2 . font-si
        0A80: 7A 65 3A 20 32 30 70 78 3B 20 66 6F 6E 74 2D 77 ze: 20px; font-w
        0A90: 65 69 67 68 74 3A 20 6E 6F 72 6D 61 6C 3B 20 63 eight: normal; c
        0AA0: 6F 6C 6F 72 3A 20 23 30 30 30 30 30 30 3B 20 6D olor: #000000; m
        0AB0: 61 72 67 69 6E 3A 20 33 34 70 78 20 30 70 78 20 argin: 34px 0px 0AC0: 30 70 78 20 30 70 78 20 7D 23 6D 65 73 73 61 67 0px 0px .#messag
        0AD0: 65 20 70 20 20 7B 20 66 6F 6E 74 2D 73 69 7A 65 e p . font-size
        0AE0: 3A 20 31 33 70 78 3B 20 63 6F 6C 6F 72 3A 20 23 : 13px; color: #
        0AF0: 30 30 30 30 30 30 3B 20 6D 61 72 67 69 6E 3A 20 000000; margin: 0B00: 37 70 78 20 30 70 78 20 30 70 78 30 70 78 7D 23 7px 0px 0px0px.#
        0B10: 65 72 72 6F 72 72 65 66 20 7B 20 66 6F 6E 74 2D errorref . font-
        0B20: 73 69 7A 65 3A 20 31 31 70 78 3B 20 63 6F 6C 6F size: 11px; colo
        0B30: 72 3A 20 23 37 33 37 33 37 33 3B 20 6D 61 72 67 r: #737373; marg
        0B40: 69 6E 2D 74 6F 70 3A 20 34 31 70 78 20 7D 3C 2F in-top: 41px .</
        0B50: 73 74 79 6C 65 3E 3C 74 69 74 6C 65 3E 43 45 53 style><title>CES
        0B60: 50 4B 49 3C 2F 74 69 74 6C 65 3E 3C 2F 68 65 61 PKI</title></hea
        0B70: 64 3E 3C 62 6F 64 79 3E 3C 64 69 76 20 69 64 3D d><body><div id=
        0B80: 27 63 6F 6E 74 65 6E 74 27 3E 3C 64 69 76 20 69 'content'><div i
        0B90: 64 3D 27 6D 65 73 73 61 67 65 27 3E 3C 68 32 3E d='message'><h2>
        0BA0: 4F 75 72 20 73 65 72 76 69 63 65 73 20 61 72 65 Our services are
        0BB0: 6E 27 74 20 61 76 61 69 6C 61 62 6C 65 20 72 69 n't available ri
        0BC0: 67 68 74 20 6E 6F 77 3C 2F 68 32 3E 3C 70 3E 57 ght now</h2><p>W
        0BD0: 65 27 72 65 20 77 6F 72 6B 69 6E 67 20 74 6F 20 e're working to 0BE0: 72 65 73 74 6F 72 65 20 61 6C 6C 20 73 65 72 76 restore all serv
        0BF0: 69 63 65 73 20 61 73 20 73 6F 6F 6E 20 61 73 20 ices as soon as 0C00: 70 6F 73 73 69 62 6C 65 2E 20 50 6C 65 61 73 65 possible. Please
        0C10: 20 63 68 65 63 6B 20 62 61 63 6B 20 73 6F 6F 6E check back soon
        0C20: 2E 3C 2F 70 3E 3C 2F 64 69 76 3E 3C 64 69 76 20 .</p></div><div 0C30: 69 64 3D 27 65 72 72 6F 72 72 65 66 27 3E 3C 73 id='errorref'><s
        0C40: 70 61 6E 3E 52 65 66 20 41 3A 20 34 33 30 46 37 pan>Ref A: 430F7
        0C50: 35 37 35 34 30 35 44 34 30 36 32 38 32 45 36 44 575405D406282E6D
        0C60: 38 41 31 32 38 33 42 43 45 35 44 20 52 65 66 20 8A1283BCE5D Ref 0C70: 42 3A 20 43 48 31 41 41 32 30 34 30 39 30 34 30 B: CH1AA20409040
        0C80: 32 35 20 52 65 66 20 43 3A 20 32 30 32 33 2D 30 25 Ref C: 2023-0
        0C90: 37 2D 32 35 54 31 38 3A 34 35 3A 32 31 5A 3C 2F 7-25T18:45:21Z</
        0CA0: 73 70 61 6E 3E 3C 2F 64 69 76 3E 3C 2F 64 69 76 span></div></div
        0CB0: 3E 3C 2F 62 6F 64 79 3E 3C 2F 68 74 6D 6C 3E 00 ></body></html>.
        

        Then with decrypted, client side saw

         "extensions": {
        "status_request (5)": {
        extra data at the end
        }
        }
        

        and failed with

         Caused by: java.io.IOException: extra data at the end
        at java.base/sun.security.util.DerValue.<init>(DerValue.java:428)
        

        The issue can be resolved when we restarted our TLS server which will get a refresh ocsp response.

        However, I wonder whether it is possible to check the status code of ocsp response, and avoid the caching when the response is not correct?

        Reproduction Steps

        intermittent issue due to ocsp responder availablity.
        maybe setup a bad ocsp responder can reproduce it stably.

        Expected behavior

        expect the retry on ocsp download or avoid cache the ocsp bad result

        Actual behavior

        the bad ocsp response is cached.

        Regression?

        No response

        Known Workarounds

        restart TLS server to fetch a new OCSP response

        Configuration

        .NET7 Kershel webserver on Linux

        Other information

        No response

        Drafted a possible fix #89908 for this issue. Please help to review

        Activity

        Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

        Metadata

        Metadata

        Assignees

        Type

        No type

        Projects

        No projects

          Milestone

          Relationships

          None yet

          Development

          No branches or pull requests

          Issue actions

          , 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
          Skip to content

          [OCSP Stapling] Cached bad response of Server-Side OCSP stabling in .NET7 Linux  #89907

          Description

          @cdlliuy

          Description

          In .NET7 Linux, we noticed that the Server Side OCSP Stapling is enabled by default, in which the response from OCSP responder is cached to speed up the cert status check

          However, if OCSP responder send back a wrong response ...it will be cached as well in TLS server side. Then ,the client of TLS server will always receive the bad extension.status_request , then failed to setup the SSL connection due to parse failure.

          From .NET runtime code, I can see the logic to do OCSP downloading , then cache for about 1 day if the response content is not null
          https://github.com/dotnet/runtime/blob/main/src/libraries/System.Net.Security/src/System/Net/Security/SslStreamCertificateContext.Linux.cs#L226C1-L249
          Then, inside the download code, I can see the bad http status code is not handled.
          https://github.com/dotnet/runtime/blob/main/src/libraries/Common/src/System/Net/Http/X509ResourceClient.cs#L182C24-L243

          What happens in our TLS server is, it tries to connection a OCSP website, and it should get a 5xx response. The OCSP website configures "an error html page" when it fails, so the response content is not empty, and our TLS server cached the error html page as the OCSP response.

          Then, when client side made a https connection to our TLS server, from the ssl debug info, we can see the error html page inside the handshake payload .. It said "Our services aren't available right now

          We're working to restore all services as soon as possible. Please check back soon"

          08F0: CE 3C 21 44 4F 43 54 59 50 45 20 68 74 6D 6C 20 .<!DOCTYPE html 0900: 50 55 42 4C 49 43 20 27 2D 2F 2F 57 33 43 2F 2F PUBLIC '-//W3C//
          0910: 44 54 44 20 58 48 54 4D 4C 20 31 2E 30 20 54 72 DTD XHTML 1.0 Tr
          0920: 61 6E 73 69 74 69 6F 6E 61 6C 2F 2F 45 4E 27 20 ansitional//EN' 0930: 27 68 74 74 70 3A 2F 2F 77 77 77 2E 77 33 2E 6F 'http://www.w3.o
          0940: 72 67 2F 54 52 2F 78 68 74 6D 6C 31 2F 44 54 44 rg/TR/xhtml1/DTD
          0950: 2F 78 68 74 6D 6C 31 2D 74 72 61 6E 73 69 74 69 /xhtml1-transiti
          0960: 6F 6E 61 6C 2E 64 74 64 27 3E 3C 68 74 6D 6C 20 onal.dtd'><html 0970: 78 6D 6C 6E 73 3D 27 68 74 74 70 3A 2F 2F 77 77 xmlns='http://ww
          0980: 77 2E 77 33 2E 6F 72 67 2F 31 39 39 39 2F 78 68 w.w3.org/1999/xh
          0990: 74 6D 6C 27 3E 3C 68 65 61 64 3E 3C 6D 65 74 61 tml'><head><meta
          09A0: 20 63 6F 6E 74 65 6E 74 3D 27 74 65 78 74 2F 68 content='text/h
          09B0: 74 6D 6C 3B 20 63 68 61 72 73 65 74 3D 75 74 66 tml; charset=utf
          09C0: 2D 38 27 20 68 74 74 70 2D 65 71 75 69 76 3D 27 -8' http-equiv='
          09D0: 63 6F 6E 74 65 6E 74 2D 74 79 70 65 27 2F 3E 3C content-type'/><
          09E0: 73 74 79 6C 65 20 74 79 70 65 3D 27 74 65 78 74 style type='text
          09F0: 2F 63 73 73 27 3E 62 6F 64 79 20 7B 66 6F 6E 74 /css'>body .font
          0A00: 2D 66 61 6D 69 6C 79 3A 41 72 69 61 6C 3B 20 6D -family:Arial; m
          0A10: 61 72 67 69 6E 2D 6C 65 66 74 3A 34 30 70 78 3B argin-left:40px;
          0A20: 20 7D 69 6D 67 20 20 7B 20 62 6F 72 64 65 72 3A .img . border:
          0A30: 30 20 6E 6F 6E 65 3B 20 7D 23 63 6F 6E 74 65 6E 0 none; .#conten
          0A40: 74 20 7B 20 6D 61 72 67 69 6E 2D 6C 65 66 74 3A t . margin-left:
          0A50: 20 61 75 74 6F 3B 20 6D 61 72 67 69 6E 2D 72 69 auto; margin-ri
          0A60: 67 68 74 3A 20 61 75 74 6F 20 7D 23 6D 65 73 73 ght: auto .#mess
          0A70: 61 67 65 20 68 32 20 7B 20 66 6F 6E 74 2D 73 69 age h2 . font-si
          0A80: 7A 65 3A 20 32 30 70 78 3B 20 66 6F 6E 74 2D 77 ze: 20px; font-w
          0A90: 65 69 67 68 74 3A 20 6E 6F 72 6D 61 6C 3B 20 63 eight: normal; c
          0AA0: 6F 6C 6F 72 3A 20 23 30 30 30 30 30 30 3B 20 6D olor: #000000; m
          0AB0: 61 72 67 69 6E 3A 20 33 34 70 78 20 30 70 78 20 argin: 34px 0px 0AC0: 30 70 78 20 30 70 78 20 7D 23 6D 65 73 73 61 67 0px 0px .#messag
          0AD0: 65 20 70 20 20 7B 20 66 6F 6E 74 2D 73 69 7A 65 e p . font-size
          0AE0: 3A 20 31 33 70 78 3B 20 63 6F 6C 6F 72 3A 20 23 : 13px; color: #
          0AF0: 30 30 30 30 30 30 3B 20 6D 61 72 67 69 6E 3A 20 000000; margin: 0B00: 37 70 78 20 30 70 78 20 30 70 78 30 70 78 7D 23 7px 0px 0px0px.#
          0B10: 65 72 72 6F 72 72 65 66 20 7B 20 66 6F 6E 74 2D errorref . font-
          0B20: 73 69 7A 65 3A 20 31 31 70 78 3B 20 63 6F 6C 6F size: 11px; colo
          0B30: 72 3A 20 23 37 33 37 33 37 33 3B 20 6D 61 72 67 r: #737373; marg
          0B40: 69 6E 2D 74 6F 70 3A 20 34 31 70 78 20 7D 3C 2F in-top: 41px .</
          0B50: 73 74 79 6C 65 3E 3C 74 69 74 6C 65 3E 43 45 53 style><title>CES
          0B60: 50 4B 49 3C 2F 74 69 74 6C 65 3E 3C 2F 68 65 61 PKI</title></hea
          0B70: 64 3E 3C 62 6F 64 79 3E 3C 64 69 76 20 69 64 3D d><body><div id=
          0B80: 27 63 6F 6E 74 65 6E 74 27 3E 3C 64 69 76 20 69 'content'><div i
          0B90: 64 3D 27 6D 65 73 73 61 67 65 27 3E 3C 68 32 3E d='message'><h2>
          0BA0: 4F 75 72 20 73 65 72 76 69 63 65 73 20 61 72 65 Our services are
          0BB0: 6E 27 74 20 61 76 61 69 6C 61 62 6C 65 20 72 69 n't available ri
          0BC0: 67 68 74 20 6E 6F 77 3C 2F 68 32 3E 3C 70 3E 57 ght now</h2><p>W
          0BD0: 65 27 72 65 20 77 6F 72 6B 69 6E 67 20 74 6F 20 e're working to 0BE0: 72 65 73 74 6F 72 65 20 61 6C 6C 20 73 65 72 76 restore all serv
          0BF0: 69 63 65 73 20 61 73 20 73 6F 6F 6E 20 61 73 20 ices as soon as 0C00: 70 6F 73 73 69 62 6C 65 2E 20 50 6C 65 61 73 65 possible. Please
          0C10: 20 63 68 65 63 6B 20 62 61 63 6B 20 73 6F 6F 6E check back soon
          0C20: 2E 3C 2F 70 3E 3C 2F 64 69 76 3E 3C 64 69 76 20 .</p></div><div 0C30: 69 64 3D 27 65 72 72 6F 72 72 65 66 27 3E 3C 73 id='errorref'><s
          0C40: 70 61 6E 3E 52 65 66 20 41 3A 20 34 33 30 46 37 pan>Ref A: 430F7
          0C50: 35 37 35 34 30 35 44 34 30 36 32 38 32 45 36 44 575405D406282E6D
          0C60: 38 41 31 32 38 33 42 43 45 35 44 20 52 65 66 20 8A1283BCE5D Ref 0C70: 42 3A 20 43 48 31 41 41 32 30 34 30 39 30 34 30 B: CH1AA20409040
          0C80: 32 35 20 52 65 66 20 43 3A 20 32 30 32 33 2D 30 25 Ref C: 2023-0
          0C90: 37 2D 32 35 54 31 38 3A 34 35 3A 32 31 5A 3C 2F 7-25T18:45:21Z</
          0CA0: 73 70 61 6E 3E 3C 2F 64 69 76 3E 3C 2F 64 69 76 span></div></div
          0CB0: 3E 3C 2F 62 6F 64 79 3E 3C 2F 68 74 6D 6C 3E 00 ></body></html>.
          

          Then with decrypted, client side saw

           "extensions": {
          "status_request (5)": {
          extra data at the end
          }
          }
          

          and failed with

           Caused by: java.io.IOException: extra data at the end
          at java.base/sun.security.util.DerValue.<init>(DerValue.java:428)
          

          The issue can be resolved when we restarted our TLS server which will get a refresh ocsp response.

          However, I wonder whether it is possible to check the status code of ocsp response, and avoid the caching when the response is not correct?

          Reproduction Steps

          intermittent issue due to ocsp responder availablity.
          maybe setup a bad ocsp responder can reproduce it stably.

          Expected behavior

          expect the retry on ocsp download or avoid cache the ocsp bad result

          Actual behavior

          the bad ocsp response is cached.

          Regression?

          No response

          Known Workarounds

          restart TLS server to fetch a new OCSP response

          Configuration

          .NET7 Kershel webserver on Linux

          Other information

          No response

          Drafted a possible fix #89908 for this issue. Please help to review

          Activity

          Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

          Metadata

          Metadata

          Assignees

          Type

          No type

          Projects

          No projects

            Milestone

            Relationships

            None yet

            Development

            No branches or pull requests

            Issue actions

            , 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
            Skip to content

            [OCSP Stapling] Cached bad response of Server-Side OCSP stabling in .NET7 Linux  #89907

            Description

            @cdlliuy

            Description

            In .NET7 Linux, we noticed that the Server Side OCSP Stapling is enabled by default, in which the response from OCSP responder is cached to speed up the cert status check

            However, if OCSP responder send back a wrong response ...it will be cached as well in TLS server side. Then ,the client of TLS server will always receive the bad extension.status_request , then failed to setup the SSL connection due to parse failure.

            From .NET runtime code, I can see the logic to do OCSP downloading , then cache for about 1 day if the response content is not null
            https://github.com/dotnet/runtime/blob/main/src/libraries/System.Net.Security/src/System/Net/Security/SslStreamCertificateContext.Linux.cs#L226C1-L249
            Then, inside the download code, I can see the bad http status code is not handled.
            https://github.com/dotnet/runtime/blob/main/src/libraries/Common/src/System/Net/Http/X509ResourceClient.cs#L182C24-L243

            What happens in our TLS server is, it tries to connection a OCSP website, and it should get a 5xx response. The OCSP website configures "an error html page" when it fails, so the response content is not empty, and our TLS server cached the error html page as the OCSP response.

            Then, when client side made a https connection to our TLS server, from the ssl debug info, we can see the error html page inside the handshake payload .. It said "Our services aren't available right now

            We're working to restore all services as soon as possible. Please check back soon"

            08F0: CE 3C 21 44 4F 43 54 59 50 45 20 68 74 6D 6C 20 .<!DOCTYPE html 0900: 50 55 42 4C 49 43 20 27 2D 2F 2F 57 33 43 2F 2F PUBLIC '-//W3C//
            0910: 44 54 44 20 58 48 54 4D 4C 20 31 2E 30 20 54 72 DTD XHTML 1.0 Tr
            0920: 61 6E 73 69 74 69 6F 6E 61 6C 2F 2F 45 4E 27 20 ansitional//EN' 0930: 27 68 74 74 70 3A 2F 2F 77 77 77 2E 77 33 2E 6F 'http://www.w3.o
            0940: 72 67 2F 54 52 2F 78 68 74 6D 6C 31 2F 44 54 44 rg/TR/xhtml1/DTD
            0950: 2F 78 68 74 6D 6C 31 2D 74 72 61 6E 73 69 74 69 /xhtml1-transiti
            0960: 6F 6E 61 6C 2E 64 74 64 27 3E 3C 68 74 6D 6C 20 onal.dtd'><html 0970: 78 6D 6C 6E 73 3D 27 68 74 74 70 3A 2F 2F 77 77 xmlns='http://ww
            0980: 77 2E 77 33 2E 6F 72 67 2F 31 39 39 39 2F 78 68 w.w3.org/1999/xh
            0990: 74 6D 6C 27 3E 3C 68 65 61 64 3E 3C 6D 65 74 61 tml'><head><meta
            09A0: 20 63 6F 6E 74 65 6E 74 3D 27 74 65 78 74 2F 68 content='text/h
            09B0: 74 6D 6C 3B 20 63 68 61 72 73 65 74 3D 75 74 66 tml; charset=utf
            09C0: 2D 38 27 20 68 74 74 70 2D 65 71 75 69 76 3D 27 -8' http-equiv='
            09D0: 63 6F 6E 74 65 6E 74 2D 74 79 70 65 27 2F 3E 3C content-type'/><
            09E0: 73 74 79 6C 65 20 74 79 70 65 3D 27 74 65 78 74 style type='text
            09F0: 2F 63 73 73 27 3E 62 6F 64 79 20 7B 66 6F 6E 74 /css'>body .font
            0A00: 2D 66 61 6D 69 6C 79 3A 41 72 69 61 6C 3B 20 6D -family:Arial; m
            0A10: 61 72 67 69 6E 2D 6C 65 66 74 3A 34 30 70 78 3B argin-left:40px;
            0A20: 20 7D 69 6D 67 20 20 7B 20 62 6F 72 64 65 72 3A .img . border:
            0A30: 30 20 6E 6F 6E 65 3B 20 7D 23 63 6F 6E 74 65 6E 0 none; .#conten
            0A40: 74 20 7B 20 6D 61 72 67 69 6E 2D 6C 65 66 74 3A t . margin-left:
            0A50: 20 61 75 74 6F 3B 20 6D 61 72 67 69 6E 2D 72 69 auto; margin-ri
            0A60: 67 68 74 3A 20 61 75 74 6F 20 7D 23 6D 65 73 73 ght: auto .#mess
            0A70: 61 67 65 20 68 32 20 7B 20 66 6F 6E 74 2D 73 69 age h2 . font-si
            0A80: 7A 65 3A 20 32 30 70 78 3B 20 66 6F 6E 74 2D 77 ze: 20px; font-w
            0A90: 65 69 67 68 74 3A 20 6E 6F 72 6D 61 6C 3B 20 63 eight: normal; c
            0AA0: 6F 6C 6F 72 3A 20 23 30 30 30 30 30 30 3B 20 6D olor: #000000; m
            0AB0: 61 72 67 69 6E 3A 20 33 34 70 78 20 30 70 78 20 argin: 34px 0px 0AC0: 30 70 78 20 30 70 78 20 7D 23 6D 65 73 73 61 67 0px 0px .#messag
            0AD0: 65 20 70 20 20 7B 20 66 6F 6E 74 2D 73 69 7A 65 e p . font-size
            0AE0: 3A 20 31 33 70 78 3B 20 63 6F 6C 6F 72 3A 20 23 : 13px; color: #
            0AF0: 30 30 30 30 30 30 3B 20 6D 61 72 67 69 6E 3A 20 000000; margin: 0B00: 37 70 78 20 30 70 78 20 30 70 78 30 70 78 7D 23 7px 0px 0px0px.#
            0B10: 65 72 72 6F 72 72 65 66 20 7B 20 66 6F 6E 74 2D errorref . font-
            0B20: 73 69 7A 65 3A 20 31 31 70 78 3B 20 63 6F 6C 6F size: 11px; colo
            0B30: 72 3A 20 23 37 33 37 33 37 33 3B 20 6D 61 72 67 r: #737373; marg
            0B40: 69 6E 2D 74 6F 70 3A 20 34 31 70 78 20 7D 3C 2F in-top: 41px .</
            0B50: 73 74 79 6C 65 3E 3C 74 69 74 6C 65 3E 43 45 53 style><title>CES
            0B60: 50 4B 49 3C 2F 74 69 74 6C 65 3E 3C 2F 68 65 61 PKI</title></hea
            0B70: 64 3E 3C 62 6F 64 79 3E 3C 64 69 76 20 69 64 3D d><body><div id=
            0B80: 27 63 6F 6E 74 65 6E 74 27 3E 3C 64 69 76 20 69 'content'><div i
            0B90: 64 3D 27 6D 65 73 73 61 67 65 27 3E 3C 68 32 3E d='message'><h2>
            0BA0: 4F 75 72 20 73 65 72 76 69 63 65 73 20 61 72 65 Our services are
            0BB0: 6E 27 74 20 61 76 61 69 6C 61 62 6C 65 20 72 69 n't available ri
            0BC0: 67 68 74 20 6E 6F 77 3C 2F 68 32 3E 3C 70 3E 57 ght now</h2><p>W
            0BD0: 65 27 72 65 20 77 6F 72 6B 69 6E 67 20 74 6F 20 e're working to 0BE0: 72 65 73 74 6F 72 65 20 61 6C 6C 20 73 65 72 76 restore all serv
            0BF0: 69 63 65 73 20 61 73 20 73 6F 6F 6E 20 61 73 20 ices as soon as 0C00: 70 6F 73 73 69 62 6C 65 2E 20 50 6C 65 61 73 65 possible. Please
            0C10: 20 63 68 65 63 6B 20 62 61 63 6B 20 73 6F 6F 6E check back soon
            0C20: 2E 3C 2F 70 3E 3C 2F 64 69 76 3E 3C 64 69 76 20 .</p></div><div 0C30: 69 64 3D 27 65 72 72 6F 72 72 65 66 27 3E 3C 73 id='errorref'><s
            0C40: 70 61 6E 3E 52 65 66 20 41 3A 20 34 33 30 46 37 pan>Ref A: 430F7
            0C50: 35 37 35 34 30 35 44 34 30 36 32 38 32 45 36 44 575405D406282E6D
            0C60: 38 41 31 32 38 33 42 43 45 35 44 20 52 65 66 20 8A1283BCE5D Ref 0C70: 42 3A 20 43 48 31 41 41 32 30 34 30 39 30 34 30 B: CH1AA20409040
            0C80: 32 35 20 52 65 66 20 43 3A 20 32 30 32 33 2D 30 25 Ref C: 2023-0
            0C90: 37 2D 32 35 54 31 38 3A 34 35 3A 32 31 5A 3C 2F 7-25T18:45:21Z</
            0CA0: 73 70 61 6E 3E 3C 2F 64 69 76 3E 3C 2F 64 69 76 span></div></div
            0CB0: 3E 3C 2F 62 6F 64 79 3E 3C 2F 68 74 6D 6C 3E 00 ></body></html>.
            

            Then with decrypted, client side saw

             "extensions": {
            "status_request (5)": {
            extra data at the end
            }
            }
            

            and failed with

             Caused by: java.io.IOException: extra data at the end
            at java.base/sun.security.util.DerValue.<init>(DerValue.java:428)
            

            The issue can be resolved when we restarted our TLS server which will get a refresh ocsp response.

            However, I wonder whether it is possible to check the status code of ocsp response, and avoid the caching when the response is not correct?

            Reproduction Steps

            intermittent issue due to ocsp responder availablity.
            maybe setup a bad ocsp responder can reproduce it stably.

            Expected behavior

            expect the retry on ocsp download or avoid cache the ocsp bad result

            Actual behavior

            the bad ocsp response is cached.

            Regression?

            No response

            Known Workarounds

            restart TLS server to fetch a new OCSP response

            Configuration

            .NET7 Kershel webserver on Linux

            Other information

            No response

            Drafted a possible fix #89908 for this issue. Please help to review

            Activity

            Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

            Metadata

            Metadata

            Assignees

            Type

            No type

            Projects

            No projects

              Milestone

              Relationships

              None yet

              Development

              No branches or pull requests

              Issue actions

              , 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
              Skip to content

              [OCSP Stapling] Cached bad response of Server-Side OCSP stabling in .NET7 Linux  #89907

              Description

              @cdlliuy

              Description

              In .NET7 Linux, we noticed that the Server Side OCSP Stapling is enabled by default, in which the response from OCSP responder is cached to speed up the cert status check

              However, if OCSP responder send back a wrong response ...it will be cached as well in TLS server side. Then ,the client of TLS server will always receive the bad extension.status_request , then failed to setup the SSL connection due to parse failure.

              From .NET runtime code, I can see the logic to do OCSP downloading , then cache for about 1 day if the response content is not null
              https://github.com/dotnet/runtime/blob/main/src/libraries/System.Net.Security/src/System/Net/Security/SslStreamCertificateContext.Linux.cs#L226C1-L249
              Then, inside the download code, I can see the bad http status code is not handled.
              https://github.com/dotnet/runtime/blob/main/src/libraries/Common/src/System/Net/Http/X509ResourceClient.cs#L182C24-L243

              What happens in our TLS server is, it tries to connection a OCSP website, and it should get a 5xx response. The OCSP website configures "an error html page" when it fails, so the response content is not empty, and our TLS server cached the error html page as the OCSP response.

              Then, when client side made a https connection to our TLS server, from the ssl debug info, we can see the error html page inside the handshake payload .. It said "Our services aren't available right now

              We're working to restore all services as soon as possible. Please check back soon"

              08F0: CE 3C 21 44 4F 43 54 59 50 45 20 68 74 6D 6C 20 .<!DOCTYPE html 0900: 50 55 42 4C 49 43 20 27 2D 2F 2F 57 33 43 2F 2F PUBLIC '-//W3C//
              0910: 44 54 44 20 58 48 54 4D 4C 20 31 2E 30 20 54 72 DTD XHTML 1.0 Tr
              0920: 61 6E 73 69 74 69 6F 6E 61 6C 2F 2F 45 4E 27 20 ansitional//EN' 0930: 27 68 74 74 70 3A 2F 2F 77 77 77 2E 77 33 2E 6F 'http://www.w3.o
              0940: 72 67 2F 54 52 2F 78 68 74 6D 6C 31 2F 44 54 44 rg/TR/xhtml1/DTD
              0950: 2F 78 68 74 6D 6C 31 2D 74 72 61 6E 73 69 74 69 /xhtml1-transiti
              0960: 6F 6E 61 6C 2E 64 74 64 27 3E 3C 68 74 6D 6C 20 onal.dtd'><html 0970: 78 6D 6C 6E 73 3D 27 68 74 74 70 3A 2F 2F 77 77 xmlns='http://ww
              0980: 77 2E 77 33 2E 6F 72 67 2F 31 39 39 39 2F 78 68 w.w3.org/1999/xh
              0990: 74 6D 6C 27 3E 3C 68 65 61 64 3E 3C 6D 65 74 61 tml'><head><meta
              09A0: 20 63 6F 6E 74 65 6E 74 3D 27 74 65 78 74 2F 68 content='text/h
              09B0: 74 6D 6C 3B 20 63 68 61 72 73 65 74 3D 75 74 66 tml; charset=utf
              09C0: 2D 38 27 20 68 74 74 70 2D 65 71 75 69 76 3D 27 -8' http-equiv='
              09D0: 63 6F 6E 74 65 6E 74 2D 74 79 70 65 27 2F 3E 3C content-type'/><
              09E0: 73 74 79 6C 65 20 74 79 70 65 3D 27 74 65 78 74 style type='text
              09F0: 2F 63 73 73 27 3E 62 6F 64 79 20 7B 66 6F 6E 74 /css'>body .font
              0A00: 2D 66 61 6D 69 6C 79 3A 41 72 69 61 6C 3B 20 6D -family:Arial; m
              0A10: 61 72 67 69 6E 2D 6C 65 66 74 3A 34 30 70 78 3B argin-left:40px;
              0A20: 20 7D 69 6D 67 20 20 7B 20 62 6F 72 64 65 72 3A .img . border:
              0A30: 30 20 6E 6F 6E 65 3B 20 7D 23 63 6F 6E 74 65 6E 0 none; .#conten
              0A40: 74 20 7B 20 6D 61 72 67 69 6E 2D 6C 65 66 74 3A t . margin-left:
              0A50: 20 61 75 74 6F 3B 20 6D 61 72 67 69 6E 2D 72 69 auto; margin-ri
              0A60: 67 68 74 3A 20 61 75 74 6F 20 7D 23 6D 65 73 73 ght: auto .#mess
              0A70: 61 67 65 20 68 32 20 7B 20 66 6F 6E 74 2D 73 69 age h2 . font-si
              0A80: 7A 65 3A 20 32 30 70 78 3B 20 66 6F 6E 74 2D 77 ze: 20px; font-w
              0A90: 65 69 67 68 74 3A 20 6E 6F 72 6D 61 6C 3B 20 63 eight: normal; c
              0AA0: 6F 6C 6F 72 3A 20 23 30 30 30 30 30 30 3B 20 6D olor: #000000; m
              0AB0: 61 72 67 69 6E 3A 20 33 34 70 78 20 30 70 78 20 argin: 34px 0px 0AC0: 30 70 78 20 30 70 78 20 7D 23 6D 65 73 73 61 67 0px 0px .#messag
              0AD0: 65 20 70 20 20 7B 20 66 6F 6E 74 2D 73 69 7A 65 e p . font-size
              0AE0: 3A 20 31 33 70 78 3B 20 63 6F 6C 6F 72 3A 20 23 : 13px; color: #
              0AF0: 30 30 30 30 30 30 3B 20 6D 61 72 67 69 6E 3A 20 000000; margin: 0B00: 37 70 78 20 30 70 78 20 30 70 78 30 70 78 7D 23 7px 0px 0px0px.#
              0B10: 65 72 72 6F 72 72 65 66 20 7B 20 66 6F 6E 74 2D errorref . font-
              0B20: 73 69 7A 65 3A 20 31 31 70 78 3B 20 63 6F 6C 6F size: 11px; colo
              0B30: 72 3A 20 23 37 33 37 33 37 33 3B 20 6D 61 72 67 r: #737373; marg
              0B40: 69 6E 2D 74 6F 70 3A 20 34 31 70 78 20 7D 3C 2F in-top: 41px .</
              0B50: 73 74 79 6C 65 3E 3C 74 69 74 6C 65 3E 43 45 53 style><title>CES
              0B60: 50 4B 49 3C 2F 74 69 74 6C 65 3E 3C 2F 68 65 61 PKI</title></hea
              0B70: 64 3E 3C 62 6F 64 79 3E 3C 64 69 76 20 69 64 3D d><body><div id=
              0B80: 27 63 6F 6E 74 65 6E 74 27 3E 3C 64 69 76 20 69 'content'><div i
              0B90: 64 3D 27 6D 65 73 73 61 67 65 27 3E 3C 68 32 3E d='message'><h2>
              0BA0: 4F 75 72 20 73 65 72 76 69 63 65 73 20 61 72 65 Our services are
              0BB0: 6E 27 74 20 61 76 61 69 6C 61 62 6C 65 20 72 69 n't available ri
              0BC0: 67 68 74 20 6E 6F 77 3C 2F 68 32 3E 3C 70 3E 57 ght now</h2><p>W
              0BD0: 65 27 72 65 20 77 6F 72 6B 69 6E 67 20 74 6F 20 e're working to 0BE0: 72 65 73 74 6F 72 65 20 61 6C 6C 20 73 65 72 76 restore all serv
              0BF0: 69 63 65 73 20 61 73 20 73 6F 6F 6E 20 61 73 20 ices as soon as 0C00: 70 6F 73 73 69 62 6C 65 2E 20 50 6C 65 61 73 65 possible. Please
              0C10: 20 63 68 65 63 6B 20 62 61 63 6B 20 73 6F 6F 6E check back soon
              0C20: 2E 3C 2F 70 3E 3C 2F 64 69 76 3E 3C 64 69 76 20 .</p></div><div 0C30: 69 64 3D 27 65 72 72 6F 72 72 65 66 27 3E 3C 73 id='errorref'><s
              0C40: 70 61 6E 3E 52 65 66 20 41 3A 20 34 33 30 46 37 pan>Ref A: 430F7
              0C50: 35 37 35 34 30 35 44 34 30 36 32 38 32 45 36 44 575405D406282E6D
              0C60: 38 41 31 32 38 33 42 43 45 35 44 20 52 65 66 20 8A1283BCE5D Ref 0C70: 42 3A 20 43 48 31 41 41 32 30 34 30 39 30 34 30 B: CH1AA20409040
              0C80: 32 35 20 52 65 66 20 43 3A 20 32 30 32 33 2D 30 25 Ref C: 2023-0
              0C90: 37 2D 32 35 54 31 38 3A 34 35 3A 32 31 5A 3C 2F 7-25T18:45:21Z</
              0CA0: 73 70 61 6E 3E 3C 2F 64 69 76 3E 3C 2F 64 69 76 span></div></div
              0CB0: 3E 3C 2F 62 6F 64 79 3E 3C 2F 68 74 6D 6C 3E 00 ></body></html>.
              

              Then with decrypted, client side saw

               "extensions": {
              "status_request (5)": {
              extra data at the end
              }
              }
              

              and failed with

               Caused by: java.io.IOException: extra data at the end
              at java.base/sun.security.util.DerValue.<init>(DerValue.java:428)
              

              The issue can be resolved when we restarted our TLS server which will get a refresh ocsp response.

              However, I wonder whether it is possible to check the status code of ocsp response, and avoid the caching when the response is not correct?

              Reproduction Steps

              intermittent issue due to ocsp responder availablity.
              maybe setup a bad ocsp responder can reproduce it stably.

              Expected behavior

              expect the retry on ocsp download or avoid cache the ocsp bad result

              Actual behavior

              the bad ocsp response is cached.

              Regression?

              No response

              Known Workarounds

              restart TLS server to fetch a new OCSP response

              Configuration

              .NET7 Kershel webserver on Linux

              Other information

              No response

              Drafted a possible fix #89908 for this issue. Please help to review

              Activity

              Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

              Metadata

              Metadata

              Assignees

              Type

              No type

              Projects

              No projects

                Milestone

                Relationships

                None yet

                Development

                No branches or pull requests

                Issue actions

                , 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
                Skip to content

                [OCSP Stapling] Cached bad response of Server-Side OCSP stabling in .NET7 Linux  #89907

                Description

                @cdlliuy

                Description

                In .NET7 Linux, we noticed that the Server Side OCSP Stapling is enabled by default, in which the response from OCSP responder is cached to speed up the cert status check

                However, if OCSP responder send back a wrong response ...it will be cached as well in TLS server side. Then ,the client of TLS server will always receive the bad extension.status_request , then failed to setup the SSL connection due to parse failure.

                From .NET runtime code, I can see the logic to do OCSP downloading , then cache for about 1 day if the response content is not null
                https://github.com/dotnet/runtime/blob/main/src/libraries/System.Net.Security/src/System/Net/Security/SslStreamCertificateContext.Linux.cs#L226C1-L249
                Then, inside the download code, I can see the bad http status code is not handled.
                https://github.com/dotnet/runtime/blob/main/src/libraries/Common/src/System/Net/Http/X509ResourceClient.cs#L182C24-L243

                What happens in our TLS server is, it tries to connection a OCSP website, and it should get a 5xx response. The OCSP website configures "an error html page" when it fails, so the response content is not empty, and our TLS server cached the error html page as the OCSP response.

                Then, when client side made a https connection to our TLS server, from the ssl debug info, we can see the error html page inside the handshake payload .. It said "Our services aren't available right now

                We're working to restore all services as soon as possible. Please check back soon"

                08F0: CE 3C 21 44 4F 43 54 59 50 45 20 68 74 6D 6C 20 .<!DOCTYPE html 0900: 50 55 42 4C 49 43 20 27 2D 2F 2F 57 33 43 2F 2F PUBLIC '-//W3C//
                0910: 44 54 44 20 58 48 54 4D 4C 20 31 2E 30 20 54 72 DTD XHTML 1.0 Tr
                0920: 61 6E 73 69 74 69 6F 6E 61 6C 2F 2F 45 4E 27 20 ansitional//EN' 0930: 27 68 74 74 70 3A 2F 2F 77 77 77 2E 77 33 2E 6F 'http://www.w3.o
                0940: 72 67 2F 54 52 2F 78 68 74 6D 6C 31 2F 44 54 44 rg/TR/xhtml1/DTD
                0950: 2F 78 68 74 6D 6C 31 2D 74 72 61 6E 73 69 74 69 /xhtml1-transiti
                0960: 6F 6E 61 6C 2E 64 74 64 27 3E 3C 68 74 6D 6C 20 onal.dtd'><html 0970: 78 6D 6C 6E 73 3D 27 68 74 74 70 3A 2F 2F 77 77 xmlns='http://ww
                0980: 77 2E 77 33 2E 6F 72 67 2F 31 39 39 39 2F 78 68 w.w3.org/1999/xh
                0990: 74 6D 6C 27 3E 3C 68 65 61 64 3E 3C 6D 65 74 61 tml'><head><meta
                09A0: 20 63 6F 6E 74 65 6E 74 3D 27 74 65 78 74 2F 68 content='text/h
                09B0: 74 6D 6C 3B 20 63 68 61 72 73 65 74 3D 75 74 66 tml; charset=utf
                09C0: 2D 38 27 20 68 74 74 70 2D 65 71 75 69 76 3D 27 -8' http-equiv='
                09D0: 63 6F 6E 74 65 6E 74 2D 74 79 70 65 27 2F 3E 3C content-type'/><
                09E0: 73 74 79 6C 65 20 74 79 70 65 3D 27 74 65 78 74 style type='text
                09F0: 2F 63 73 73 27 3E 62 6F 64 79 20 7B 66 6F 6E 74 /css'>body .font
                0A00: 2D 66 61 6D 69 6C 79 3A 41 72 69 61 6C 3B 20 6D -family:Arial; m
                0A10: 61 72 67 69 6E 2D 6C 65 66 74 3A 34 30 70 78 3B argin-left:40px;
                0A20: 20 7D 69 6D 67 20 20 7B 20 62 6F 72 64 65 72 3A .img . border:
                0A30: 30 20 6E 6F 6E 65 3B 20 7D 23 63 6F 6E 74 65 6E 0 none; .#conten
                0A40: 74 20 7B 20 6D 61 72 67 69 6E 2D 6C 65 66 74 3A t . margin-left:
                0A50: 20 61 75 74 6F 3B 20 6D 61 72 67 69 6E 2D 72 69 auto; margin-ri
                0A60: 67 68 74 3A 20 61 75 74 6F 20 7D 23 6D 65 73 73 ght: auto .#mess
                0A70: 61 67 65 20 68 32 20 7B 20 66 6F 6E 74 2D 73 69 age h2 . font-si
                0A80: 7A 65 3A 20 32 30 70 78 3B 20 66 6F 6E 74 2D 77 ze: 20px; font-w
                0A90: 65 69 67 68 74 3A 20 6E 6F 72 6D 61 6C 3B 20 63 eight: normal; c
                0AA0: 6F 6C 6F 72 3A 20 23 30 30 30 30 30 30 3B 20 6D olor: #000000; m
                0AB0: 61 72 67 69 6E 3A 20 33 34 70 78 20 30 70 78 20 argin: 34px 0px 0AC0: 30 70 78 20 30 70 78 20 7D 23 6D 65 73 73 61 67 0px 0px .#messag
                0AD0: 65 20 70 20 20 7B 20 66 6F 6E 74 2D 73 69 7A 65 e p . font-size
                0AE0: 3A 20 31 33 70 78 3B 20 63 6F 6C 6F 72 3A 20 23 : 13px; color: #
                0AF0: 30 30 30 30 30 30 3B 20 6D 61 72 67 69 6E 3A 20 000000; margin: 0B00: 37 70 78 20 30 70 78 20 30 70 78 30 70 78 7D 23 7px 0px 0px0px.#
                0B10: 65 72 72 6F 72 72 65 66 20 7B 20 66 6F 6E 74 2D errorref . font-
                0B20: 73 69 7A 65 3A 20 31 31 70 78 3B 20 63 6F 6C 6F size: 11px; colo
                0B30: 72 3A 20 23 37 33 37 33 37 33 3B 20 6D 61 72 67 r: #737373; marg
                0B40: 69 6E 2D 74 6F 70 3A 20 34 31 70 78 20 7D 3C 2F in-top: 41px .</
                0B50: 73 74 79 6C 65 3E 3C 74 69 74 6C 65 3E 43 45 53 style><title>CES
                0B60: 50 4B 49 3C 2F 74 69 74 6C 65 3E 3C 2F 68 65 61 PKI</title></hea
                0B70: 64 3E 3C 62 6F 64 79 3E 3C 64 69 76 20 69 64 3D d><body><div id=
                0B80: 27 63 6F 6E 74 65 6E 74 27 3E 3C 64 69 76 20 69 'content'><div i
                0B90: 64 3D 27 6D 65 73 73 61 67 65 27 3E 3C 68 32 3E d='message'><h2>
                0BA0: 4F 75 72 20 73 65 72 76 69 63 65 73 20 61 72 65 Our services are
                0BB0: 6E 27 74 20 61 76 61 69 6C 61 62 6C 65 20 72 69 n't available ri
                0BC0: 67 68 74 20 6E 6F 77 3C 2F 68 32 3E 3C 70 3E 57 ght now</h2><p>W
                0BD0: 65 27 72 65 20 77 6F 72 6B 69 6E 67 20 74 6F 20 e're working to 0BE0: 72 65 73 74 6F 72 65 20 61 6C 6C 20 73 65 72 76 restore all serv
                0BF0: 69 63 65 73 20 61 73 20 73 6F 6F 6E 20 61 73 20 ices as soon as 0C00: 70 6F 73 73 69 62 6C 65 2E 20 50 6C 65 61 73 65 possible. Please
                0C10: 20 63 68 65 63 6B 20 62 61 63 6B 20 73 6F 6F 6E check back soon
                0C20: 2E 3C 2F 70 3E 3C 2F 64 69 76 3E 3C 64 69 76 20 .</p></div><div 0C30: 69 64 3D 27 65 72 72 6F 72 72 65 66 27 3E 3C 73 id='errorref'><s
                0C40: 70 61 6E 3E 52 65 66 20 41 3A 20 34 33 30 46 37 pan>Ref A: 430F7
                0C50: 35 37 35 34 30 35 44 34 30 36 32 38 32 45 36 44 575405D406282E6D
                0C60: 38 41 31 32 38 33 42 43 45 35 44 20 52 65 66 20 8A1283BCE5D Ref 0C70: 42 3A 20 43 48 31 41 41 32 30 34 30 39 30 34 30 B: CH1AA20409040
                0C80: 32 35 20 52 65 66 20 43 3A 20 32 30 32 33 2D 30 25 Ref C: 2023-0
                0C90: 37 2D 32 35 54 31 38 3A 34 35 3A 32 31 5A 3C 2F 7-25T18:45:21Z</
                0CA0: 73 70 61 6E 3E 3C 2F 64 69 76 3E 3C 2F 64 69 76 span></div></div
                0CB0: 3E 3C 2F 62 6F 64 79 3E 3C 2F 68 74 6D 6C 3E 00 ></body></html>.
                

                Then with decrypted, client side saw

                 "extensions": {
                "status_request (5)": {
                extra data at the end
                }
                }
                

                and failed with

                 Caused by: java.io.IOException: extra data at the end
                at java.base/sun.security.util.DerValue.<init>(DerValue.java:428)
                

                The issue can be resolved when we restarted our TLS server which will get a refresh ocsp response.

                However, I wonder whether it is possible to check the status code of ocsp response, and avoid the caching when the response is not correct?

                Reproduction Steps

                intermittent issue due to ocsp responder availablity.
                maybe setup a bad ocsp responder can reproduce it stably.

                Expected behavior

                expect the retry on ocsp download or avoid cache the ocsp bad result

                Actual behavior

                the bad ocsp response is cached.

                Regression?

                No response

                Known Workarounds

                restart TLS server to fetch a new OCSP response

                Configuration

                .NET7 Kershel webserver on Linux

                Other information

                No response

                Drafted a possible fix #89908 for this issue. Please help to review

                Activity

                Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

                Metadata

                Metadata

                Assignees

                Type

                No type

                Projects

                No projects

                  Milestone

                  Relationships

                  None yet

                  Development

                  No branches or pull requests

                  Issue actions