Title: Microsoft GovCloud fails HostnameUtil.checkHostname · Issue #1202 · bcgit/bc-java · GitHub
Open Graph Title: Microsoft GovCloud fails HostnameUtil.checkHostname · Issue #1202 · bcgit/bc-java
X Title: Microsoft GovCloud fails HostnameUtil.checkHostname · Issue #1202 · bcgit/bc-java
Description: Code: `import java.net.URL; import java.io.InputStream; public class BCExample { public static void main(String[] args){ if (args.length != 1) { System.out.println("Usage: "+BCExample.class.getName()+"
Open Graph Description: Code: `import java.net.URL; import java.io.InputStream; public class BCExample { public static void main(String[] args){ if (args.length != 1) { System.out.println("Usage: "+BCExample.class.getName...
X Description: Code: `import java.net.URL; import java.io.InputStream; public class BCExample { public static void main(String[] args){ if (args.length != 1) { System.out.println("Usage: "+BCExample.cla...
Opengraph URL: https://github.com/bcgit/bc-java/issues/1202
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Microsoft GovCloud fails HostnameUtil.checkHostname","articleBody":"**Code:** \r\n`import java.net.URL; \r\nimport java.io.InputStream;\r\n\r\npublic class BCExample { \r\n public static void main(String[] args){\r\n\r\n if (args.length != 1) {\r\n System.out.println(\"Usage: \"+BCExample.class.getName()+\" \u003cURL> \");\r\n System.out.println(\"Example: java -Djdk.tls.trustNameService=true BCExample https://login.microsoftonline.us\");\r\n System.exit(1);\r\n }\r\n\r\n try{ \r\n InputStream response =new URL(args[0]).openStream(); \r\n } \r\n catch(Exception e){ \r\n System.out.println(e);\r\n }\r\n } \r\n} `\r\n\r\n**Problem**\r\nUsing BC we found the following situation when we try to go against https://login.microsoftonline.us\r\n\r\norg.bouncycastle.tls.TlsFatalAlert: certificate_unknown(46)\r\n\tat org.bouncycastle.jsse.provider.ProvSSLSocketDirect.checkServerTrusted(ProvSSLSocketDirect.java:135)\r\n\tat org.bouncycastle.jsse.provider.ProvTlsClient$1.notifyServerCertificate(ProvTlsClient.java:360)\r\n\tat org.bouncycastle.tls.TlsUtils.processServerCertificate(TlsUtils.java:4889)\r\n\tat org.bouncycastle.tls.TlsClientProtocol.handleServerCertificate(TlsClientProtocol.java:788)\r\n\tat org.bouncycastle.tls.TlsClientProtocol.handleHandshakeMessage(TlsClientProtocol.java:671)\r\n\tat org.bouncycastle.tls.TlsProtocol.processHandshakeQueue(TlsProtocol.java:708)\r\n\tat org.bouncycastle.tls.TlsProtocol.processRecord(TlsProtocol.java:584)\r\n\tat org.bouncycastle.tls.RecordStream.readRecord(RecordStream.java:245)\r\n\tat org.bouncycastle.tls.TlsProtocol.safeReadRecord(TlsProtocol.java:856)\r\n\tat org.bouncycastle.tls.TlsProtocol.blockForHandshake(TlsProtocol.java:417)\r\n\tat org.bouncycastle.tls.TlsClientProtocol.connect(TlsClientProtocol.java:88)\r\n\tat org.bouncycastle.jsse.provider.ProvSSLSocketDirect.startHandshake(ProvSSLSocketDirect.java:445)\r\n\tat org.bouncycastle.jsse.provider.ProvSSLSocketDirect.startHandshake(ProvSSLSocketDirect.java:426)\r\n\tat sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:559)\r\n\tat sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:197)\r\n\tat sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1570)\r\n\tat sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1498)\r\n\tat sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:268)\r\n\tat java.net.URL.openStream(URL.java:1068)\r\n\tat BCExample.main(BCExample.java:14)\r\nCaused by: java.security.cert.CertificateException: No subject alternative name found matching domain name login.microsoftonline.us\r\n\tat org.bouncycastle.jsse.provider.HostnameUtil.checkHostname(HostnameUtil.java:97)\r\n\tat org.bouncycastle.jsse.provider.ProvX509TrustManager.checkEndpointID(ProvX509TrustManager.java:334)\r\n\tat org.bouncycastle.jsse.provider.ProvX509TrustManager.checkEndpointID(ProvX509TrustManager.java:453)\r\n\tat org.bouncycastle.jsse.provider.ProvX509TrustManager.checkExtendedTrust(ProvX509TrustManager.java:362)\r\n\tat org.bouncycastle.jsse.provider.ProvX509TrustManager.checkTrusted(ProvX509TrustManager.java:275)\r\n\tat org.bouncycastle.jsse.provider.ProvX509TrustManager.checkServerTrusted(ProvX509TrustManager.java:182)\r\n\tat org.bouncycastle.jsse.provider.ProvSSLSocketDirect.checkServerTrusted(ProvSSLSocketDirect.java:131)\r\n\t... 19 more\r\n\r\nThis works if we try it with https://login.microsoftonline.com and we found that BC always try to match hostname in the URL with 2nd entry in \"SubjectAlternativeName/DNSName\" in the certificate.\r\n\r\n1. [login.microsoftonline.us](https://login.microsoftonline.us/)\r\n\r\n SubjectAlternativeName [\r\n DNSName: [login.microsoftonline.us](https://login.microsoftonline.us/)\r\n DNSName: [certauth.login.microsoftonline.us](https://certauth.login.microsoftonline.us/)\r\n DNSName: [device.login.microsoftonline.us](https://device.login.microsoftonline.us/)\r\n DNSName: [logincert.microsoftonline.us](https://logincert.microsoftonline.us/)\r\n ]\r\n\r\n 2. [login.microsoftonline.com](https://login.microsoftonline.com/)\r\n SubjectAlternativeName [\r\n DNSName: [stamp2.login.microsoftonline.com](https://stamp2.login.microsoftonline.com/)\r\n DNSName: [login.microsoftonline-int.com](https://login.microsoftonline-int.com/)\r\n DNSName: [login.microsoftonline-p.com](https://login.microsoftonline-p.com/)\r\n DNSName: [login.microsoftonline.com](https://login.microsoftonline.com/)\r\n DNSName: [login2.microsoftonline-int.com](https://login2.microsoftonline-int.com/)\r\n DNSName: [login2.microsoftonline.com](https://login2.microsoftonline.com/)\r\n DNSName: [loginex.microsoftonline-int.com](https://loginex.microsoftonline-int.com/)\r\n DNSName: [loginex.microsoftonline.com](https://loginex.microsoftonline.com/)\r\n DNSName: [stamp2.login.microsoftonline-int.com](https://stamp2.login.microsoftonline-int.com/)\r\n ]\r\n\r\nHow we can see the 2nd entry in https://login.microsoftonline.us/ has certauth and it doesn’t match, but in https://login.microsoftonline.com/ the 2nd entry has login and in this case works.\r\n\r\n**Step to reproduce**\r\n1. Generate the app with the code shared\r\n2. Configure BC in your environment \r\n3. Run the following command /DIRECTORY-OF-YOUR-APP/java -Djdk.tls.trustNameService=true BCExample https://login.microsoftonline.us","author":{"url":"https://github.com/gdovalMule","@type":"Person","name":"gdovalMule"},"datePublished":"2022-08-05T18:26:51Z","url":"https://github.com/bcgit/bc-java/issues/1202"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:c9871ca0-857d-1f51-3db5-2ceb65cb7115 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C02C:1566C6:1D971A:28A81E:6AFBFFA2 |
| html-safe-nonce | 46632f5ffd7ddf081a35ab70a1b48aa44a2f389e3be82f22c8e1e9d29bca0c7e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMDJDOjE1NjZDNjoxRDk3MUE6MjhBODFFOjZBRkJGRkEyIiwidmlzaXRvcl9pZCI6IjU2NTQxNjk2Nzc4MzIzODg1MTQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 69bcfc115391b83fedf647d884e8751f9cbd5fbcb2fe65ac8964f9abde59a739 |
| hovercard-subject-tag | issue:1330246204 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/bcgit/bc-java/1202/issue_layout |
| twitter:image | https://opengraph.githubassets.com/bd757a06ecece3e1b8a3825297c861b200fb3876626c12f891f51cc1a24d06b8/bcgit/bc-java/issues/1202 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/bd757a06ecece3e1b8a3825297c861b200fb3876626c12f891f51cc1a24d06b8/bcgit/bc-java/issues/1202 |
| og:image:alt | Code: `import java.net.URL; import java.io.InputStream; public class BCExample { public static void main(String[] args){ if (args.length != 1) { System.out.println("Usage: "+BCExample.class.getName... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | gdovalMule |
| hostname | github.com |
| expected-hostname | github.com |
| None | fa74413a1d84dac536fcca0740780bcbd3207bafec0e51873b73ff8e8cca032f |
| turbo-cache-control | no-preview |
| go-import | github.com/bcgit/bc-java git https://github.com/bcgit/bc-java.git |
| octolytics-dimension-user_id | 4566970 |
| octolytics-dimension-user_login | bcgit |
| octolytics-dimension-repository_id | 10416648 |
| octolytics-dimension-repository_nwo | bcgit/bc-java |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 10416648 |
| octolytics-dimension-repository_network_root_nwo | bcgit/bc-java |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | b3b5633a74535d9c23385512d534c66c8fde1907 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width