Оно начинается со следующего класса:
Код: Выделить всё
public class DescargaMensajesEntidadesInit {
private static Logger log = LoggerFactory.getLogger(DescargaMensajesEntidadesInit.class);
public static void main(String[] args) {
// TODO Apéndice de método generado automáticamente
//Verificamos que se pasen tres argumentos
if (args.length < 4) {
log.warn("Uso: java Main ");
return;
}
//Primer argumento: La identificación de la aplicación
String idAplicacion = args[0];
//Segundo argumento: ruta al archivo de certificado
String rutaCertificado = args[1];
File certificado = new File(rutaCertificado);
//Tercer argumento: clave del certificado
String claveCertificado = args[2];
//Cuarto argumento: entidad (debe cumplir con la expresión regular [0-9]{8})
String entidad = args[3];
String patronEntidad = "[0-9]{10}";
//Validamos que el argumento "entidad" cumple con la expresión regular
if (!entidad.matches(patronEntidad)) {
log.warn("Error: La entidad debe ser un string de 10 dígitos (ejemplo: 1234567890).");
return;
}
//Verificamos si el archivo de certificado existe y es un archivo
if (certificado.exists() && certificado.isFile()) {
log.info("Identificacion de la aplicacion: " + idAplicacion);
log.info("Ruta del certificado: " + rutaCertificado);
log.info("Clave del certificado: " + claveCertificado);
log.info("Entidad: " + entidad);
//Llamamos al Servicio descarga de mensajes
DescargaMensajesEntrada entrada = new DescargaMensajesEntrada();
entrada.setIdAplicacion(idAplicacion);
entrada.setFicheroP12(rutaCertificado);
entrada.setPasswordP12(claveCertificado.toCharArray());
entrada.setIdEntidad(entidad);
String respuesta = descargaMensajesEntidades(entrada);
log.info(respuesta);
} else {
log.warn("El archivo de certificado no existe o no es un archivo válido.");
}
}
private static String descargaMensajesEntidades(DescargaMensajesEntrada entrada) {
String respuesta = "";
try {
DescargaMensajesEntidadesReturn response = new DescargaMensajesEntidadesReturn();
DescargarMensajesEntidadesService descargarMensajesEntidadesService = new DescargarMensajesEntidadesServiceImpl();
response = descargarMensajesEntidadesService.ejecutar(entrada);
respuesta = response.getRespuestaCorrecta().getOut();
if("".equals(respuesta) || respuesta == null) {
respuesta = response.getError().getTexto();
}
} catch (DescargaMensajesEntidadesFault_Exception e) {
// TODO Bloque catch generado automáticamente
log.error("Problemas en el servicio de Descarga de mensajes, motivo: " + e.getMessage());
}
return respuesta;
}
}
Но когда я экспортирую его в исполняемый файл .jar (который будет работать в других средах) я запускаю его так:
java -Djavax.net.ssl.trustStore=CERTLEXNET.p12
-Djavax.net.ssl.trustStorePassword=8ba73c7240 -jar palex.jar "PALEXWS" "/certificado/CERTLEXNET.p12" "8ba73c7240" "2807906202"
Происходит следующая ошибка:
sun.security.validator.ValidatorException: не удалось построить путь PKIX:
sun.security.provider.certpath.SunCertPathBuilderException: невозможно
найти действительный путь сертификации к запрошенной цели
javax .net.ssl.SSLHandshakeException:
sun.security.validator.ValidatorException: не удалось построить путь PKIX:
sun.security.provider.certpath.SunCertPathBuilderException: невозможно
найти действительный путь сертификации к запрошенной цели
в sun.security.ssl.Alert.createSSLException(Unknown Source)
в sun. Security.ssl.TransportContext.fatal(Неизвестный источник)
at sun.security.ssl.TransportContext.fatal(Неизвестный источник)
at sun.security.ssl.TransportContext.fatal(Unknown Source)
at sun.security.ssl.CertificateMessage$T12CertificateConsumer.checkServerCerts(Unknown
Source)
at sun.security.ssl.CertificateMessage$ T12CertificateConsumer.onCertificate(Неизвестно
Источник)
at sun.security.ssl.CertificateMessage$T12CertificateConsumer.consume(Неизвестный
Источник)
at sun.security.ssl.SSLHandshake.consume(Неизвестный источник)
в sun.security.ssl.HandshakeContext.dispatch (неизвестный источник)
в sun.security.ssl.HandshakeContext.dispatch(неизвестный источник)
at sun.security.ssl.TransportContext.dispatch(неизвестный источник)
at sun.security.ssl.SSLTransport.decode(неизвестный источник)at sun.security.ssl.SSLSocketImpl.decode (неизвестный источник)
at sun.security.ssl.SSLSocketImpl.readHandshakeRecord(Неизвестный источник)
at sun.security.ssl.SSLSocketImpl.startHandshake(Неизвестный источник)
at sun.security.ssl.SSLSocketImpl.startHandshake(Неизвестный источник)в org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory.executeHandshake(SSLConnectionSocketFactory.java:350)
at org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory.createLayeredSocket(SSLConnectionSocketFactory.java:318)
at org.apache.hc.client5.http.impl.io.DefaultHttpClientConnectionOperator.lambda$null$0(DefaultHttpClientConnectionOperator.java:104)
at org.apache.hc.client5.http.impl.io.DefaultHttpClientConnectionOperator.upgrade(DefaultHttpClientConnectionOperator.java:284)
at org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager.upgrade(PoolingHttpClientConnectionManager.java :516)
at org.apache.hc.client5.http.impl.classic.InternalExecRuntime.upgradeTls(InternalExecRuntime.java:195)
at org.apache.hc.client5.http.impl.classic.ConnectExec.execute( ConnectExec.java:173)
at org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
на org.apache.hc.client5.http.impl.classic.ProtocolExec.execute(ProtocolExec.java :192)
в org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
на org.apache.hc.client5.http.impl.classic.HttpRequestRetryExec.execute(HttpRequestRetryExec.java :113)
в org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
на org.apache.hc.client5.http.impl.classic.ContentCompressionExec.execute(ContentCompressionExec.java :147)
в org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
на org.apache.hc.client5.http.impl.classic.RedirectExec.execute(RedirectExec.java :111)
в org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
на org.apache.hc.client5.http.impl.classic.InternalHttpClient.doExecute(InternalHttpClient.java :174)
в org.apache.hc.client5.http.impl.classic.CloseableHttpClient.execute(CloseableHttpClient.java:123)
at es.seguridadsocial.palexws.descargarmensajes.LoginServiciosGeneralImpl.llamarWS(LoginServiciosGeneralImpl.java:184)
в es.seguridadsocial.palexws.descargarmensajes.LoginServiciosGeneralImpl.getLoginServiciosGeneral(LoginServiciosGeneralImpl.java:66)
at es.seguridadsocial.palexws.service.DescargarMensajesEntidadesServiceImpl.loginServiciosGeneral(DescargarMensajesEntidadesServiceImpl.java:106)
at es.seguridadsocial.palexws.service.DescargarMensajesEntidadesServiceImpl.ejecutar(DescargarMensajesEntidadesServiceImpl.java:62)
at es.seguridadsocial.palexws.inicio.DescargaMensajesEntidadesInit.descargaMensajesEntidades(DescargaMensajesEntidadesInit.java:74)
at es.seguridadsocial.palexws.inicio.DescargaMensajesEntidadesInit.main(DescargaMensajesEntidadesInit.java:57)
Вызвано: sun.security.validator.ValidatorException: путь PKIX
не удалось построить:
sun.security. поставщик.certpath.SunCertPathBuilderException: невозможно
найти действительный путь сертификации для запрошенной цели
в sun.security.validator.PKIXValidator.doBuild(Unknown Source)
at sun.security.validator.PKIXValidator.engineValidate(Unknown Source)
at sun.security.validator.Validator.validate(неизвестный источник)
at sun.security.ssl.X509TrustManagerImpl.validate(Неизвестный источник)
at sun.security.ssl.X509TrustManagerImpl.checkTrusted(Неизвестный источник)
at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(Unknown
Источник)
... еще 36
Я не знаю, связано ли это с версиями Java, поскольку jar был создан с помощью jdk1.8.0_231 и в CMD, когда я запускаю < strong>java -version он говорит мне jre1.8.0_431
Можете ли вы мне помочь?
Спасибо большое.
Подробнее здесь: https://stackoverflow.com/questions/791 ... ted-target