Skip to content

Commit 18f3379

Browse files
Merge pull request #341 from fredwilliamtjr/fix/consulta-tributacao-multithreading
Fix: SSL Handshake Error in Multithreading Mode (ConsultaTributacao)
2 parents 7e384db + 79bd240 commit 18f3379

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

src/main/java/br/com/swconsultoria/nfe/ConsultaTributacao.java

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public static String getJson(ConfiguracoesNfe config, Map<String, String> queryP
134134
try {
135135
HttpClient httpClient = createHttpClient(config, certificado, url);
136136
if (httpClient != null) {
137-
return executeRequestWithHttpClient(httpClient, url);
137+
return executeRequestWithHttpClient(httpClient, url, certificado);
138138
}
139139
} catch (CertificadoException e) {
140140
log.warning("[ConsultaTributacao] Falha ao criar HttpClient, tentando fallback: " + e.getMessage());
@@ -506,8 +506,21 @@ private static HttpClient createHttpClient(ConfiguracoesNfe config, Certificado
506506
}
507507
}
508508

509-
private static String executeRequestWithHttpClient(HttpClient httpClient, String url) throws IOException {
510-
GetMethod getMethod = new GetMethod(url);
509+
private static String executeRequestWithHttpClient(HttpClient httpClient, String url, Certificado certificado) throws IOException {
510+
String uri = url;
511+
if (certificado.isModoMultithreading()) {
512+
if (httpClient.getHostConfiguration().getProtocol() != null) {
513+
try {
514+
URL u = new URL(url);
515+
httpClient.getHostConfiguration().setHost(u.getHost(), u.getPort(), httpClient.getHostConfiguration().getProtocol());
516+
uri = u.getFile();
517+
} catch (Exception e) {
518+
log.warning("[ConsultaTributacao] Erro ao processar URL para modo multithreading: " + e.getMessage());
519+
}
520+
}
521+
}
522+
523+
GetMethod getMethod = new GetMethod(uri);
511524

512525
try {
513526
getMethod.setRequestHeader("Accept", "application/json");

0 commit comments

Comments
 (0)