java.security.InvalidAlgorithmParameterException: only SM2ParameterSpec supported
SM2ParameterSpec parameterSpec = new SM2ParameterSpec(userId); Signature signer = Signature.getInstance("SM3withSM2", "BC"); signer.setParameter(parameterSpec);
An error is reported when the Spring Framework is upgraded from 5.x to 6.0
"java.security.InvalidAlgorithmParameterException: only SM2ParameterSpec supported"
The local ut is normal, but the deployment to the online environment is abnormal.
Can this information help analyze the root cause?
The error message is from the BC provider, which is expecting an instance of org.bouncycastle.jcajce.spec.SM2ParameterSpec, so double-check that is the type in your code. If you are using the right type, then the problem is almost certainly a classpath issue; most likley cause would be multiple versions of the bouncycastle jars in the runtime classpath. You may need to check which version of the bouncycastle jars your spring dependencies are including.
The error message is from the BC provider, which is expecting an instance of
org.bouncycastle.jcajce.spec.SM2ParameterSpec, so double-check that is the type in your code. If you are using the right type, then the problem is almost certainly a classpath issue; most likley cause would be multiple versions of the bouncycastle jars in the runtime classpath. You may need to check which version of the bouncycastle jars your spring dependencies are including.
The version is 1.78.1. “the problem is almost certainly a classpath issue” Does this mean that Spring 5 is upgraded to 6, discarding javax and enabling the new jakarta namespace?
I am saying Spring may include some bouncycastle jars, and upgrading from 5 to 6 may have changed the version of those bouncycastle jars and created a classpath conflict with the bouncycastle jars you are including directly.