On Java 17 and later, secure validation mode is enabled by default. On Java 11 and 8, secure validation mode is enabled by default only when running with a SecurityManager, otherwise it is disabled by default.
The org.jcp.xml.dsig.secureValidation system property can be used to enable or disable the XML Signature secure validation mode. Set the value to "true" to enable, or "false" to disable. Any other value is treated as "false".
If the system property is set, it supersedes the XMLCryptoContext property value of the same name.
Disabling secure validation mode is done at your own risk.
Here are some other XML related Java system properties:
java.xml.config.filejavax.xml.accessExternalDTDjdk.xml.elementAttributeLimitjdk.xml.enableExtensionFunctionsjdk.xml.entityExpansionLimitjdk.xml.maxXMLNameLimitJava has supported the org.jcp.xml.dsig.secureValidation system property since Java 8u401, 11.0.22, 17.0.10, 21.0.2.
org.jcp.xml.dsig.secureValidation on StartupYou can set the org.jcp.xml.dsig.secureValidation java system property during startup of the java runtime using the -D command line argument:
java -Dorg.jcp.xml.dsig.secureValidation=true MyAppMain
You may also be able to specify org.jcp.xml.dsig.secureValidation via the JAVA_TOOL_OPTIONS environment variable:
JAVA_TOOL_OPTIONS=-Dorg.jcp.xml.dsig.secureValidation=true
org.jcp.xml.dsig.secureValidation at RuntimeYou can set org.jcp.xml.dsig.secureValidation at runtime with the following Java code:
System.setProperty("org.jcp.xml.dsig.secureValidation", "true");
WARNING: Depending on the property and JVM version using
setPropertymay or may not work if the JDK Java class that uses this variable has already been loaded. The value of the org.jcp.xml.dsig.secureValidation system property may be cached within an internal private static variable of the implementing class.
To read the value of org.jcp.xml.dsig.secureValidation at runtime, you can use this Java code:
String propertyValue = System.getProperty("org.jcp.xml.dsig.secureValidation");
if (propertyValue != null) {
System.out.println("org.jcp.xml.dsig.secureValidation = " + propertyValue);
} else {
System.out.println("org.jcp.xml.dsig.secureValidation was null");
}