2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] lich.tool.encryptionAndDecryption.EncryptionAndDecryptionException: java.lang.reflect.InvocationTargetException
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at lich.tool.encryptionAndDecryption.asymmetric.AsymmetricTool.encrypt(AsymmetricTool.java:38)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at com.dianju.SM.Sm2Utils.SM2Encrypt(Sm2Utils.java:58)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at com.dianju.modules.documentGTSM.controllers.SecretDocumentController.getSecretKey(SecretDocumentController.java:1440)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at com.dianju.modules.documentGTSM.controllers.SecretDocumentController$$FastClassBySpringCGLIB$$f1f4683f.invoke(<generated>)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:738)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:85)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at "writeLog.WriteLogAspect.before(WriteLogAspect.java:44)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at java.lang.reflect.Method.invoke(Method.java:606)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:629)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:618)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:70)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:673)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at com.dianju.modules.documentGTSM.controllers.SecretDocumentController$$EnhancerBySpringCGLIB$$f0064dd4.getSecretKey(<generated>)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at java.lang.reflect.Method.invoke(Method.java:606)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:133)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:97)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:967)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:901)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at "writeLog.CopyRequestBodyFilter.doFilter(CopyRequestBodyFilter.java:25)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:108)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:81)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at org.springframework.boot.web.support.ErrorPageFilter.doFilter(ErrorPageFilter.java:115)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at org.springframework.boot.web.support.ErrorPageFilter.access$000(ErrorPageFilter.java:59)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at org.springframework.boot.web.support.ErrorPageFilter$1.doFilterInternal(ErrorPageFilter.java:90)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at org.springframework.boot.web.support.ErrorPageFilter.doFilter(ErrorPageFilter.java:108)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:110)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:444)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:1025)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:445)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1137)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:317)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at java.lang.Thread.run(Thread.java:745)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] Caused by: java.lang.reflect.InvocationTargetException
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at java.lang.reflect.Method.invoke(Method.java:606)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at lich.tool.conflictResolution.ClassProxy.exec(ClassProxy.java:144)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at lich.tool.encryptionAndDecryption.asymmetric.AsymmetricTool.encrypt(AsymmetricTool.java:36)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] ... 83 more
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] Caused by: java.security.InvalidKeyException: Illegal key size or default parameters
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at javax.crypto.Cipher.checkCryptoPerm(Cipher.java:1016)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at javax.crypto.Cipher.init(Cipher.java:1229)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at javax.crypto.Cipher.init(Cipher.java:1173)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] at lich.tool.encryptionAndDecryption.core.asymmetric.AsymmetricTool.encrypt(AsymmetricTool.java:74)
[2021-03-29 17:21:56] ["SystemOutPrint]-[INFO] ... 89 more
原因:
在Java的核心类库中有一个JCE(Java Cryptography Extension),JCE是一组包,它们提供用于加密、密钥生成和协商以及 Message Authentication Code(MAC)算法的框架和实现,所以这个是实现加密解密的重要类库。
JRE中自带的“local_policy.jar ”和“US_export_policy.jar”是支持128位密钥的加密算法,而当我们要使用256位密钥算法的时候,已经超出它的范围,无法支持,秘钥长度不能满足需求,所以才会报:“java.security.InvalidKeyException: Illegal key size or default parameters”的异常。
解决方案:
替换无限制秘钥长度的jar包,替换自身jdk自带的jar包local_policy.jar和US_export_policy.jar
jdk7资源下载
https://download.csdn.net/download/qq_25078011/16290365
jdk8资源下载
https://download.csdn.net/download/qq_25078011/16290468