Is there a way for java's keytool to generate self-signed certificate with a wildcard in SAN (Subject Alternative Name)? I'm using this command to generate keystore:
keytool -genkey -alias tomcat -storetype JKS -keyalg RSA -keysize 2048 -ext san=dns:*.example.com -keystore "path/to/my/keystore.jks" -validity 3650
But I get IOException: DNSName components must begin with a letter
Obviously, the problem is *.example.com
in SAN, but I don't see other way of generating self-signed certificate for example.com
subdomains.
According to this, it should be possible. Is it error in my syntax, bug in keytool, or I misunderstood something?
BTW, I'm using keytool from JDK 1.8 update 60
EDIT I managed to generate self-signed certificate for all example.com
subdomains via keytool by specifying CN=*.example.com
, and leaving SAN empty. Nonetheless, I'll leave Omikron's answer as accepted (since it's an actual answer and not a bypass of restrictions).