zoukankan      html  css  js  c++  java
  • DER input, Integer tag error的异常处理

    1、首先我向大家介绍一下我做的东西,发生这个异常的情况。

      我做的是一个电签的系统,在调用某公司的API生成证书,然后与安证通进行同步证书的任务。

    2、问题具体的异常

      具体异常如下:

    2016/08/29 15:19:25 : INFO [com.bjazt.easysign.server.SyncServiceImpl] 进入同步接口:<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <ROWDATA>
        <ROW xsi:type="aztCert" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <CERTID>SYNC110101198912129995</CERTID>
            <USERID>110101198912129995</USERID>
            <OPTYPE>A</OPTYPE>
            <PASSWORD>itrusyes</PASSWORD>
            <PFX>MIIM9wYJKoZIhvcNAQcCoIIM6DCCDOQCAQExADALBgkqhkiG9w0BBwGgggzMMIIDwzCCAqugAwIBAgIUYfdQUqQxBCEGlELPLH3RBkuei9UwDQYJKoZIhvcNAQEFBQAwaTEjMCEGA1UEAwwa5aSp5aiB6K+a5L+hUlNB5rWL6K+V5qC5Q0ExEjAQBgNVBAsMCVJTQea1i+ivlTEhMB8GA1UECgwY5aSp5aiB6K+a5L+h5rWL6K+V57O757ufMQswCQYDVQQGEwJDTjAeFw0xNjA1MDcxMTQxMzhaFw0zNjA1MDIxMTQxMzhaMGkxIzAhBgNVBAMMGuWkqeWogeivmuS/oVJTQea1i+ivleaguUNBMRIwEAYDVQQLDAlSU0HmtYvor5UxITAfBgNVBAoMGOWkqeWogeivmuS/oea1i+ivleezu+e7nzELMAkGA1UEBhMCQ04wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDZ48CCSv2qk3hBSKIdkCilUZDK9KUi2XHpq3xcndUWREesGhEQunqjC6gTX9KV9jW+h++GqM2t8S3lIrED86BmfNkGniwS2lw3LCY+zTsGRrpVN7U7barcs3LC/N0mWgRmYxQmqn8bvinmacxu1mS6x6QVkwbYHHJKcjIuTObefCGLmcQP5NTO2MJHNK5892o7EE1SE4iEVR6SydN8q2/+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TZiZGRlYTAzMDQyMTkzYTlkMDEzME8GA1UdHwRIMEYwRKBCoECGPlBvcnQvVG9wQ0EvcHVibGljL2l0cnVzY3JsP0NBPTMxZjcxY2NiOGVlOTZiZGRlYTAzMDQyMTkzYTlkMDEzMA0GCSqGSIb3DQEBBQUAA4IBAQDSeEgUBQJFIjIUvAK9lwcNUNBSjbdrhkHBK0jkaQxO7Hbxz78Roa9mzoUIZaOLsBFxYij30Y9TUfUNVI4lCLf11azOD4+qQo+Z3iHNnGKDZpB3rhtLFkyREE48kXwASyFvlb5wXGw6pl6QOVSarxvw0JzAIHOkCIVmXkWn6EjkF4S2xF+lpETJx9V6MCib9qdvhFy3izAqRN6ieGypuXzpSmgjilDzBtzpDqZq9GnyJdfIOP7Ij2xCT1vf5gjs/HTp2Xr26BERaS8+dU8iqkbLLClFh7zwztbRghmki06eoVOI3NvOF4QdgNouFD8hyIAACNdzc/F6RMyKgRX9tJu6MQA=</PFX>
        </ROW>
    </ROWDATA>
    
    2016/08/29 15:19:25 : INFO [com.bjazt.easysign.server.SyncServiceImpl] 将XML转为Bean,开始
    java.io.IOException: DER input, Integer tag error
        at sun.security.util.DerInputStream.getInteger(DerInputStream.java:151)
        at com.sun.net.ssl.internal.pkcs12.PKCS12KeyStore.engineLoad(PKCS12KeyStore.java:1202)
        at java.security.KeyStore.load(KeyStore.java:1185)
        at com.esa2000.datasync.common.SystemUtil.validateCertificate(SystemUtil.java:483)
        at com.esa2000.datasync.document.XmlToPfxCert.toObject(XmlToPfxCert.java:45)
        at com.esa2000.datasync.document.XmlToBean.toObjectList(XmlToBean.java:31)
        at com.esa2000.datasync.document.XmlToBean.toObject(XmlToBean.java:47)
        at com.bjazt.easysign.server.SyncServiceImpl.sync(SyncServiceImpl.java:26)
        at com.bjazt.easysign.server.SyncServiceImpl.syncPfxCert(SyncServiceImpl.java:50)
        at sun.reflect.GeneratedMethodAccessor188.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.axis2.rpc.receivers.RPCUtil.invokeServiceClass(RPCUtil.java:194)
        at org.apache.axis2.rpc.receivers.RPCMessageReceiver.invokeBusinessLogic(RPCMessageReceiver.java:102)
        at org.apache.axis2.receivers.AbstractInOutMessageReceiver.invokeBusinessLogic(AbstractInOutMessageReceiver.java:40)
        at org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:100)
        at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:176)
        at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:275)
        at org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:133)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:643)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:620)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
        at java.lang.Thread.run(Thread.java:662)
    2016/08/29 15:19:25 : ERROR [com.esa2000.datasync.document.XmlToPfxCert] 
    java.io.IOException: DER input, Integer tag error
        at sun.security.util.DerInputStream.getInteger(DerInputStream.java:151)
        at com.sun.net.ssl.internal.pkcs12.PKCS12KeyStore.engineLoad(PKCS12KeyStore.java:1202)
        at java.security.KeyStore.load(KeyStore.java:1185)
        at com.esa2000.datasync.common.SystemUtil.validateCertificate(SystemUtil.java:483)
        at com.esa2000.datasync.document.XmlToPfxCert.toObject(XmlToPfxCert.java:45)
        at com.esa2000.datasync.document.XmlToBean.toObjectList(XmlToBean.java:31)
        at com.esa2000.datasync.document.XmlToBean.toObject(XmlToBean.java:47)
        at com.bjazt.easysign.server.SyncServiceImpl.sync(SyncServiceImpl.java:26)
        at com.bjazt.easysign.server.SyncServiceImpl.syncPfxCert(SyncServiceImpl.java:50)
        at sun.reflect.GeneratedMethodAccessor188.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.axis2.rpc.receivers.RPCUtil.invokeServiceClass(RPCUtil.java:194)
        at org.apache.axis2.rpc.receivers.RPCMessageReceiver.invokeBusinessLogic(RPCMessageReceiver.java:102)
        at org.apache.axis2.receivers.AbstractInOutMessageReceiver.invokeBusinessLogic(AbstractInOutMessageReceiver.java:40)
        at org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:100)
        at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:176)
        at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:275)
        at org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:133)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:643)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:620)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
        at java.lang.Thread.run(Thread.java:662)

     3、解决问题

      错误的原因是证书的申请是pkcs7格式的生成,但是安证通同步解析用到的是pkcs12,造成编码解码不一致的问题。

      起初就是jar包的冲突问题,bcprov-jdk15-1.46.jar 没有向下兼容bcprov-jdk15-1.43.jar,因为这其中的DERSequence方法的构造方法不同。大家可以自行的下载看看。

      最后我们是在申请证书之后,用证书去获取这个pfx格式的编码,然后去用安证通同步,这样就解决了这个问题。(因为这是第三方的东西,所以要和第三方进行沟通,他们提供了一个新的方法来获取证书的pfx格式编码)。

      4、总结

      遇见jar包冲突的问题,解决的根本方法就是去掉冲突的jar,留下一个我们用到的jar包,否则,就算解决了,项目上线也会有很多的问题的。

      5、美诗美句

      少年不识愁滋味,爱上层楼,爱上层楼,为赋新词强说愁。

      而今识尽愁滋味,欲说还秀,欲说还休,却道天凉好个秋。

      

  • 相关阅读:
    Vulkan
    C# Optimization
    C# Bridge Pattern(Handle/Body)
    Favorite Games
    Unity Particle System Sorting Order
    UGUI
    C# Language Specification
    接口的显式实现和隐式实现
    C#反射机制
    wcf 使用sqlMembership证书认证
  • 原文地址:https://www.cnblogs.com/lixiaochao/p/6015879.html
Copyright © 2011-2022 走看看