Boa tarde a todos. Ha alguns dias estou enfrentando um problema estranho, com os servidores da SEFAZ no Paraná e Goiás.
Consigo obter os certificados publicos, e adicionalos no meu TrustStore, porem, parece que os certificados da SEFAZ são inválidos, e sempre exibem excessões fatais quando tento utilizar os WebServices.
Observem a conexao feita no Webservice de São Paulo:
Obtendo certificado, e construindo truststore
Dec 27, 2010 1:47:19 PM ConfiguracaoTrustKey log
INFO: Carregando KeyStore /tmp/EDeployerTrustStore...
Dec 27, 2010 1:47:19 PM ConfiguracaoTrustKey log
INFO: Conectando em nfe.fazenda.sp.gov.br:443...
Dec 27, 2010 1:47:20 PM ConfiguracaoTrustKey log
INFO: Iniciando handshake SSL (Negociando obtencao de certificado publico...)
Dec 27, 2010 1:47:22 PM ConfiguracaoTrustKey log
INFO: Nenhum erro. Este certificado ja havia sido cadastrado no TrustStore...
1 Subject CN=nfe.fazenda.sp.gov.br, OU=Autenticado por Imprensa Oficial SP RFB, OU=RFB e-Servidor A1, OU=Secretaria da Receita Federal do Brasil - RFB, O=ICP-Brasil, C=BR
Issuer CN=AC Imprensa Oficial SP RFB G2, OU=Secretaria da Receita Federal do Brasil - RFB, O=ICP-Brasil, C=BR
Validade: Wed Mar 31 21:00:00 BRT 2010 - Thu Mar 31 20:59:59 BRT 2011
sha1 94 b2 46 c2 c6 ee f3 8c 08 6e 84 20 c6 50 de 0f e3 e9 f2 f5
md5 22 8f 7e 5a b7 dc ce 97 51 f6 e5 3f fd 78 79 fb
Adicionando certificado ao trustStore
2 Subject CN=AC Imprensa Oficial SP RFB G2, OU=Secretaria da Receita Federal do Brasil - RFB, O=ICP-Brasil, C=BR
Issuer CN=AC Secretaria da Receita Federal do Brasil, O=ICP-Brasil, C=BR
Validade: Wed Oct 29 15:14:43 BRST 2008 - Sat Oct 29 15:14:43 BRST 2016
sha1 50 67 6c 4f d7 1b 13 8f 07 59 cf ee b5 aa 47 d6 cc 0c a8 b9
md5 72 0d a1 ae 0a 5a 4d c8 83 4c 91 a6 24 5e 1b b4
Adicionando certificado ao trustStore
3 Subject CN=AC Secretaria da Receita Federal do Brasil, O=ICP-Brasil, C=BR
Issuer CN=Autoridade Certificadora Raiz Brasileira v1, OU=Instituto Nacional de Tecnologia da Informacao - ITI, O=ICP-Brasil, C=BR
Validade: Fri Oct 24 10:39:46 BRST 2008 - Wed Oct 24 10:39:46 BRST 2018
sha1 1f 97 ae 58 a3 c2 53 58 18 7a 7d 9b f0 71 ad b1 76 f0 93 2f
md5 c4 73 8c 2b c0 51 08 29 dd ec 14 d4 6b ef 39 8a
Adicionando certificado ao trustStore
Efetuando conexao no serviço:
java -Djavax.net.ssl.trustStore=/tmp/EDeployerTrustStore SSLPoke nfe.fazenda.sp.gov.br 443
Successfully connected
Agora, repetindo os procedimentos com o Paraná
java -Djavax.net.ssl.trustStore=/tmp/EDeployerTrustStore ConfiguracaoTrustKey https://nfe.fazenda.pr.gov.br
Dec 27, 2010 1:47:35 PM ConfiguracaoTrustKey log
INFO: Carregando KeyStore /tmp/EDeployerTrustStore...
Dec 27, 2010 1:47:36 PM ConfiguracaoTrustKey log
INFO: Conectando em nfe.fazenda.pr.gov.br:443...
Dec 27, 2010 1:47:37 PM ConfiguracaoTrustKey log
INFO: Iniciando handshake SSL (Negociando obtencao de certificado publico...)
Dec 27, 2010 1:47:39 PM ConfiguracaoTrustKey log
INFO: Houve uma excessao na conexao SSL. E provavel que este certificado ainda nao esteja armazenado na TrustStore. Neste caso, ele sera armazenado
javax.net.ssl.SSLHandshakeException: Received fatal alert: bad_certificate
at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:174)
at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:136)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.recvAlert(SSLSocketImpl.java:1720)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:954)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1138)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1165)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1149)
at ConfiguracaoTrustKey.addHostToTrustStore(ConfiguracaoTrustKey.java:268)
at ConfiguracaoTrustKey.executar(ConfiguracaoTrustKey.java:185)
at ConfiguracaoTrustKey.main(ConfiguracaoTrustKey.java:54)
1 Subject CN=nfe.fazenda.pr.gov.br, OU=ARSERPRO, OU=RFB e-CNPJ/EA, OU=Secretaria da Receita Federal do Brasil - RFB, O=ICP-Brasil, C=BR
Issuer CN=Autoridade Certificadora do SERPRORFB, OU=Secretaria da Receita Federal do Brasil - RFB, O=ICP-Brasil, C=BR
Validade: Fri Nov 26 10:28:01 BRST 2010 - Sat Nov 26 10:27:08 BRST 2011
sha1 79 8a 6c 1f 15 86 32 c3 af a6 ff 2a 52 83 8a b5 82 83 aa 97
md5 67 f1 03 d7 e3 7f ee 15 91 bc f1 5a b0 2c 5d 95
Adicionando certificado ao trustStore
2 Subject CN=Autoridade Certificadora do SERPRORFB, OU=Secretaria da Receita Federal do Brasil - RFB, O=ICP-Brasil, C=BR
Issuer CN=AC Secretaria da Receita Federal do Brasil, O=ICP-Brasil, C=BR
Validade: Sat Nov 08 10:34:38 BRST 2008 - Tue Nov 08 10:34:38 BRST 2016
sha1 a7 28 fc 25 69 d9 d8 98 4f 7c df 26 75 35 93 d4 4b c3 4d b1
md5 fb cf 1f 08 71 00 ab 73 44 84 db a3 17 2b 65 fb
Adicionando certificado ao trustStore
3 Subject CN=AC Secretaria da Receita Federal do Brasil, O=ICP-Brasil, C=BR
Issuer CN=Autoridade Certificadora Raiz Brasileira v1, OU=Instituto Nacional de Tecnologia da Informacao - ITI, O=ICP-Brasil, C=BR
Validade: Fri Oct 24 10:39:46 BRST 2008 - Wed Oct 24 10:39:46 BRST 2018
sha1 1f 97 ae 58 a3 c2 53 58 18 7a 7d 9b f0 71 ad b1 76 f0 93 2f
md5 c4 73 8c 2b c0 51 08 29 dd ec 14 d4 6b ef 39 8a
Adicionando certificado ao trustStore
4 Subject CN=Autoridade Certificadora Raiz Brasileira v1, OU=Instituto Nacional de Tecnologia da Informacao - ITI, O=ICP-Brasil, C=BR
Issuer CN=Autoridade Certificadora Raiz Brasileira v1, OU=Instituto Nacional de Tecnologia da Informacao - ITI, O=ICP-Brasil, C=BR
Validade: Tue Jul 29 16:17:10 BRT 2008 - Thu Jul 29 16:17:10 BRT 2021
sha1 70 5d 2b 45 65 c7 04 7a 54 06 94 a7 9a f7 ab b8 42 bd c1 61
md5 93 f1 ad 34 0b 2b e7 a8 54 60 e2 73 8c a4 94 31
Adicionando certificado ao trustStore
java -Djavax.net.ssl.trustStore=/tmp/EDeployerTrustStore SSLPoke nfe.fazenda.pr.gov.br 443
javax.net.ssl.SSLHandshakeException: Received fatal alert: bad_certificate
at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:174)
at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:136)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.recvAlert(SSLSocketImpl.java:1720)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:954)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1138)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.writeRecord(SSLSocketImpl.java:632)
at com.sun.net.ssl.internal.ssl.AppOutputStream.write(AppOutputStream.java:59)
at com.sun.net.ssl.internal.ssl.AppOutputStream.write(AppOutputStream.java:73)
at SSLPoke.main(SSLPoke.java:31)
Agora, um exemplo da aplicação em produção:
org.apache.axis2.AxisFault: Connection has been shutdown: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.pro
vider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430)
at org.apache.axis2.transport.http.SOAPMessageFormatter.writeTo(SOAPMessageFormatter.java:83)
at org.apache.axis2.transport.http.AxisRequestEntity.writeRequest(AxisRequestEntity.java:84)
at org.apache.commons.httpclient.methods.EntityEnclosingMethod.writeRequestBody(EntityEnclosingMethod.java:499)
at org.apache.commons.httpclient.HttpMethodBase.writeRequest(HttpMethodBase.java:2114)
at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:1096)
at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:398)
at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:346)
at org.apache.axis2.transport.http.AbstractHTTPSender.executeMethod(AbstractHTTPSender.java:560)
at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:199)
at org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:76)
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:400)
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:225)
at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:435)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:402)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
at br.com.simus.supera.nfewswrapper.wsclients.nfev1.NfeRecepcaoStub.nfeRecepcaoLote(NfeRecepcaoStub.java:181)
at br.com.simus.supera.nfewswrapper.service.nfev1.NfeServiceV1RecepcaoImpl.consumirWebService(NfeServiceV1RecepcaoImpl.java:28)
at br.com.simus.supera.nfewswrapper.service.AbstractNfeService.processar(AbstractNfeService.java:89)
Ficaria muito grato se alguem desse alguma dica…
Grande abraço.