Keytool在内部使用类sun.security.x509.DNSName来检查输入. DNSName强制执行
RFC 1034中指定的语法.引用其Javadoc注释:
The name MUST be in the “preferred name syntax,” as specified by RFC
1034.
首选名称语法是:
::= | " "
::= | "."
::= [ [ ] ]
::= |
::= | "-"
::= |
::= any one of the 52 alphabetic characters A through Z in
upper case and a through z in lower case
::= any one of the ten digits 0 through 9
因此,根据这种语法,域名必须以字母(A-Z,a-z)开头.
较新的RFC(例如RFC 2181,RFC 1123)正在放宽这些限制,因此这可以被视为Java中的一个错误.已经有几个相关的错误报告:
所以,答案是否定的,目前无法使用keytool创建通配符SAN扩展.
但你可以使用KeyStore Explorer来做到这一点.它基本上是带有GUI的keytool,并不强制实施这些限制.