문제

JSF 응용 프로그램에 대한 이상한 문제가 있습니다. 현재 일하고 있습니다. 그것은 충돌하는 내 프로그램의 두 부분이있는 것처럼 보입니다.

두 부분이 있습니다 :

  • "뱅킹"기능
  • 메일 기능

은행 기능의 관련 부분 (이 운동을 위해 가짜 은행) :

String path = FacesContext.getCurrentInstance().getExternalContext()                .getRealPath("/") + "/WEB-INF/sec/certs.jks";

ErrorHandler.trace(path);

System.setProperty("javax.net.ssl.trustStore", path);
.

여기에서는 은행 서버의 인증서가있는 신뢰 저장소를 설정하고 있습니다.

mail 부분은 다음과 같습니다 :

Properties props = new Properties();
props.put("mail.smtp.auth", this.smtpServer.isAuthenticated());
props.put("mail.smtp.starttls.enable", this.smtpServer.isTls());
props.put("mail.smtp.host", this.smtpServer.getHostaddr());
props.put("mail.smtp.port", this.smtpServer.getPort());
props.put("mail.smtps.auth", "true");
props.put("mail.smtp.debug", "true");

final String username = this.smtpServer.getUsername();
final String password = this.smtpServer.getPassword();

Session session = Session.getDefaultInstance(props,
        new javax.mail.Authenticator() {
            @Override
            protected PasswordAuthentication getPasswordAuthentication() {
                return new PasswordAuthentication(username, password);
            }
        });

session.setDebug(true);
.

문제를 재현하는 한 가지 방법 :

문제가 발생하는 문제는 응용 프로그램을 시작하면 "메일 변경"기능을 사용하면 즉시 내 알림 메일을 가져올 수 있습니다. 거기에 문제가 없습니다. 그런 다음 은행 기능을 유발하는 제품을 구입하려고 노력할 것입니다.

문제가 나타나는 위치 :

Communication Error: javax.ws.rs.WebApplicationException: javax.xml.bind.MarshalException
 - with linked exception:
[javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target]
.

문제를 재현하는 또 다른 방법 :

이제는 응용 프로그램을 다시 시작하고 이번에는 작동 할 것이지만이 오류 메시지가 표시됩니다.

DEBUG: setDebug: JavaMail version 1.4.7
DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Oracle]
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: trying to connect to host "smtp.gmail.com", port 465, isSSL true
TRACE Error Could not connect to SMTP host: smtp.gmail.com, port: 465
.

rown line :

i는 은행을 트리거하고 메일을 방아쇠 -> 메일이 작동하지 않음 메일을 방아쇠하고 은행 -> 은행이 작동하지 않으면

문제를 찾을 수있는 사람은 누구나?

고맙습니다!

도움이 되었습니까?

해결책

"뱅킹 기능"이 신뢰 저장소를 변경하는 것입니다.새로운 신뢰 저장소에는 메일 서버와 SSL 연결의 SSL 연결을 확인하는 데 필요한 인증서가 필요합니다.JDK 기본 트러스트 스토어의 모든 CA 인증서로 신뢰 저장소를 초기화하거나 메일 서버에 대한 특정 인증서 만 추가 할 수 있습니다. installcert 프로그램.마지막으로 별도의 트러스트 스토어를 사용하도록 JavaMail을 구성하거나 은행 기능을 기본 트러스트 스토어를 재정의하는 대신 신뢰 저장소를 사용하도록 변경할 수 있습니다.그것들은 아마도 더 복잡합니다.

다른 팁

트러스트 스토어 세트가 없으면 메일 기능이 작동하지 않았습니다 (시스템의 기본 트러스트 스토어를 사용하고 있기 때문에 :

/Library/Java/JavaVirtualMachines/jdk1.7.0_25.jdk/Contents/Home/jre/lib/security/cacerts
.

Mac.

은행 기능은 다음과 같은 자체 인증서를 사용하고 있습니다 :

MyProject/.../WEB-INF/sec/certs.jks
.

Javamail이 Google의 SMTP 서버에 인증을 시도 할 때마다 TrustStore 속성을 송금하지 않아도 Certs.jks 트러스트 스토어를 사용하려고 시도했지만 뱅킹 기능이 메일 메서드에 설정되어 있습니다.

수정 :

메일 방법의 시작 부분 :

String path = FacesContext.getCurrentInstance().getExternalContext()
            .getRealPath("/")
            + "WEB-INF/sec/certs.jks";
System.setProperty("javax.net.ssl.trustStore", path);
.

기본 cacerts 키 스토어를 자체 사용자 정의 키 저장소로 가져 오십시오 :

keytool -importkeystore -srckeystore certs.jks -destkeystore cacerts
.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top