I have an ASP.NET MVC application hosted on Azure App Service, and I've set up an Application Gateway with an SSL certificate. When a user tries to access an invalid URL, I currently don't handle the error, and the browser displays its default 404 page.
The problem is that this default 404 page shows an SSL error ('Your connection to the site is not secure'), even when the domain part of the URL is valid and only the last segment after the slash is misspelled. How can I address this issue?
I reproduced your issue in my side, check the screenshot below. When facing 404 error, the browser showed insecure warning. If test with Edge, and clicking into the warning, it would indicate "doesn't have a certificate".
If we are facing the same issue, then it's not due to SSL certificate, but the browser itself. Or we can say it's recognized as the expected behavior. Here's a question which had the same concern with you. And here's a GitHub issue reported before.
Generally speaking, 404 is also a kind of error which is considered as insecure so that the browser reported a warning, in Edge it also showed "no certificate". What we can do now is adding a handler for 404 error, such as set a custom page which displaying friendly message like "sorry the page is missing" in our application to avoid the real 404 error appearing in users' view.