Why IE rejects a self-signed localhost certificate for 127.0.0.1 only, when Chrome accepts it?

☆樱花仙子☆ 提交于 2019-12-04 08:43:19

IE does not support IP addresses values in Subject Alternative Name (SAN), only DNS entries.

This is a known limitation that won't be fixed, according to Microsoft:

We do not support using the IP choice in the Subject Alternative name to match the server name. You can work around this by adding the IP address as a string for a DNS name choice. At this time we do not plan on fixing this issue.

So the correct way to handle it is to add a DNS entry containing the IP address:

"dns:127.0.0.1"

Unfortunately, this is not possible using keytool or programmatically with sun.security.x509 classes because of Java bug 8016345.

It is however possible to fix this bug by yourself, just by copying the latest version of DNSName.java and remove this check:

//DNSName components must begin with a letter A-Z or a-z
if (alpha.indexOf(name.charAt(startIndex)) < 0)
    throw new IOException("DNSName components must begin with a letter");

Why not just issue a HTTP 301 redirect when users use 127.0.0.1 sending them to localhost instead?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!