Nota fiscal Eletrônica: javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
2 respostas
B
Berkamps
Pessoal,
Eu percebi que já houveram vários tópicos relacionados a comunicação webservice para o envio de notas fiscais eletronicas, mas nenhum com a solução do problema:
Como foi adicionado.
Todos os problemas que tive de ‘handshake’ foram problemas com certificado.
B
Berkamps
publicstaticvoidmain(String[]args)throwsException{HttpSecureProtocolf=newHttpSecureProtocol();// might as well trust the usual suspects: f.addTrustMaterial(TrustMaterial.JSSE_CACERTS);// here's where we start trusting usertrust.com's CA: //FileInputStream stream = new FileInputStream ("certificate.cer");FileInputStreamstream=newFileInputStream("base64.cer");f.addTrustMaterial(newTrustMaterial(stream));ProtocoltrustHttps=newProtocol("https",f,443);Protocol.registerProtocol("https",trustHttps);HttpClientclient=newHttpClient();GetMethodhttpget=newGetMethod("https://hnfe.fazenda.mg.gov.br/nfe/services/CadConsultaCadastro/");//GetMethod httpget = new GetMethod("https://www.usertrust.com/"); client.executeMethod(httpget);StringstatusLine=httpget.getStatusLine().toString();Stringbody=httpget.getResponseBodyAsString();System.out.println("HTTPClient: "+statusLine);// Notice that Java still can't access it. Only HTTPClient knows // to trust the cert! URLu=newURL("https://www.usertrust.com/");try{// This will throw an SSLHandshakeException u.openStream();}catch(SSLHandshakeExceptionshe){System.out.println("Java: "+she);}}