qq_29697901
张恒_ZH
2018-10-19 09:36
采纳率: 80%
浏览 2.3k
已采纳

java.io.IOException: stream does not represent a PKCS12 key store

本地环境 windows7 apache8.5 java1.8 eclipse编辑器 springmvc项目

服务器环境 linux apache8.5 java1.8

                问题描述:使用openssl生成 private-rsa.kek **.pfx **.cer 三个文件,在本地运行没事,上传服务器后宝以下错误:
 java.io.IOException: stream does not represent a PKCS12 key store
    at org.bouncycastle.jce.provider.JDKPKCS12KeyStore.engineLoad(Unknown Source)
    at java.security.KeyStore.load(KeyStore.java:1445)
    at com.yufusoft.payplatform.security.util.RSAComUtil.getKsformPfxByInputStream(RSAComUtil.java:161)
    at com.yufusoft.payplatform.security.util.RSAComUtil.getPvkformPfxByInputStream(RSAComUtil.java:114)
    at com.yufusoft.payplatform.security.cipher.BiDirSignWithYufuCipherImpl.<init>(BiDirSignWithYufuCipherImpl.java:28)
    at com.yufusoft.payplatform.security.cipher.YufuCipherFactory.createWithRSA(YufuCipherFactory.java:46)
    at com.cn.yhc.all.yf.YufuCipherSupport.getCipherInstance(YufuCipherSupport.java:35)
    at com.cn.yhc.all.yf.PaySet.doPaySet(PaySet.java:32)
    at com.cn.yhc.all.yf.YFPayInstruction.getOrderInstruction(YFPayInstruction.java:108)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.cn.yhc.customannotation.Scanner.getPayMapping(Scanner.java:183)
    at com.cn.yhc.receive.ReceivePayInstruction.doPost(ReceivePayInstruction.java:77)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:661)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:108)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:496)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803)
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:790)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1468)
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:748)

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

3条回答 默认 最新

  • qq_29697901
    张恒_ZH 2018-11-06 09:04
    已采纳

    解决了,linux上运行加载这几个文件有问题,Windows可以。最后解决方法是:使用openssl将私钥和公钥导出来

    点赞 评论
  • liuade
    艾德 2018-10-19 10:42

    我猜是因为路径问题,导致没有读到文件。或者权限问题导致文件不让读。

    java-doc是这么说的:
    IOException - if there is an I/O or format problem with thekeystore data, if a password is required but not given,or if the given password was incorrect. If the error is due to awrong password, the cause of the IOException should be an UnrecoverableKeyException

    说IOException要么文件格式不对,要么密码不对

    点赞 评论
  • c_hoped
    c_hoped 2018-10-22 02:52

    看提示,你的哪个方法对应的哪一句有问题。

    点赞 评论

相关推荐