Код: Выделить всё
openjdk version "21.0.4" 2024-07-16 LTS
OpenJDK Runtime Environment Temurin-21.0.4+7 (build 21.0.4+7-LTS)
OpenJDK 64-Bit Server VM Temurin-21.0.4+7 (build 21.0.4+7-LTS, mixed mode, sharing)
< /code>
[*] jsp и java servlets: используется для логики фронта и бэкэнд. Files \ Java \ jdk1.7.0_80 \ jre < /li>
Path: C: C: \ Program Files \ Java \ jdk1.7.0_80 < /li>
tomcat Path: C: \ Program Files \ Programice Foundation \ Tomcat 9.0 < /li>
Catalina Program Foundation \ Tomcat 9.0 \ conf \ catalina < /li>
< /ul>
< /li>
База данных: Postgresql 42.2.2.29 Driver (Postgresql jdbc) < /p>
< /li>
< /ul>
Основная проблема: Основная проблема с паролем. Я продолжаю получать ошибку рукопожатия SSL всякий раз, когда система пытается отправить электронное письмо. Ниже приведено полное сообщение об ошибке: < /p>
javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate)
at sun.security.ssl.HandshakeContext.(HandshakeContext.java:171)
at sun.security.ssl.ClientHandshakeContext.(ClientHandshakeContext.java:101)
at sun.security.ssl.TransportContext.kickstart(TransportContext.java:238)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:394)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:373)
at com.sun.mail.util.SocketFetcher.configureSSLSocket(SocketFetcher.java:549)
at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:354)
at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:237)
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1927)
< /code>
Эта проблема появляется всякий раз, когда система пытается подключиться к почтовому серверу через SSL для отправки электронных писем. (jbcrypt-0.4.jar)
[*] javamail api (mail-1.4.7.jar, smtp-1.6.2. /> recovery_account.jsp
// THIS IS THE MAIN CODE THAT IS SENDING EMAILS (RECOVERY_ACCOUNT.JSP)
// Database connection configurations
String url = "jdbc:postgresql://localhost:5432/bibliotech";
String user = "postgres";
String password = "admin";
String email = request.getParameter("email");
String passwordHash = null;
try {
// Connect to the database
Class.forName("org.postgresql.Driver");
Connection conn = DriverManager.getConnection(url, user, password);
enter code here
// Query to check if the email exists
String query = "SELECT password_hash FROM USERS WHERE email = ?";
PreparedStatement ps`enter code here`tmt = conn.prepareStatement(query);
pstmt.setString(1, email);
ResultSet rs = pstmt.executeQuery();
if (rs.next()) {
passwordHash = rs.getString("password_hash"); // Retrieve the password hash
} else {
out.println("alert('Email not found!'); window.location.href = 'recovery.jsp';");
}
rs.close();
pstmt.close();
conn.close();
} catch (Exception e) {
e.printStackTrace();
}
// If the password hash was found, send an email to the user
if (passwordHash != null) {
// JavaMail configurations
String host = "smtp.gmail.com"; // Using Gmail as an example
String from = "bibliotechproject@gmail.com"; // Your email
String appPassword = "************"; // Use a Gmail app password
String to = email;
String subject = "Password Recovery - Bibliotech";
// Email content with HTML
String messageText =
""
+ ""
+ "
[img]https://iili.io/dPzedMX.png[/img]
"
+ ""
+ "Account Recovery"
+ "
Hello,
"
+ "
We received a request to recover the password for your account. Here are your login details:
"
+ "
Email: " + email + "
"
+ "
Password: " + passwordHash + "
"
+ "
If you did not make this request, please ignore this email.
"
+ "
Sincerely, https://prod.liveshare.vsengsaas.visualstudio.com/join?01A2BDE3A14A18BC1D1E0892E16E13D31189
"
+ "
Support Team - Bibliotech
"
+ ""
+ ""
+ "";
Properties props = System.getProperties();
props.put("mail.smtp.starttls.enable", "true");
props.put("mail.smtp.host", host);
props.put("mail.smtp.user", from);
props.put("mail.smtp.password", appPassword);
props.put("mail.smtp.port", "587");
props.put("mail.debug", "true");
props.put("mail.smtp.ssl.enable", "true");
props.put("mail.smtp.auth", "true");
Session mailSession = Session.getDefaultInstance(props, null);
MimeMessage message = new MimeMessage(mailSession);
try {
message.setFrom(new InternetAddress(from));
message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
message.setSubject(subject);
message.setContent(messageText, "text/html");
Transport transport = mailSession.getTransport("smtp");
transport.connect(host, from, appPassword);
transport.sendMessage(message, message.getAllRecipients());
transport.close();
response.sendRedirect("send_success.jsp");
} catch (Exception e) {
e.printStackTrace();
}
}
us_export_policy.jar
/>[*] Javax.Activation.jar
[*]jbcrypt-0.4 /> postgresql-42.2.29.jre7.jar
[*]smtp-1.6.2.jar
< /ul>
То, что я пробовал: < /p>
Обдуманное протокол SSL включено на сервере и в My javam just. JavaMail library to resolve potential SSL protocol mismatches.
Looked at the order of the JARs in the lib folder to check for conflicting libraries.
Remaining Questions:
Is the SSL handshake error related to my Java 21 version, or is it a misconfiguration in the JavaMail or Tomcat server?
Could the issue stem from older versions of Javamail или другие файлы JAR, вызывающие конфликты с протоколами SSL? Как вы решили проблему рукопожатия SSL? Если это вопрос версий JAR, каковы были бы правильные версии и упорядочение этих библиотек? В тот же день, когда я снова тестировал на той же машине, это снова дало мне ошибку при отправке электронных писем.
Подробнее здесь: https://stackoverflow.com/questions/790 ... jsp-projec
Мобильная версия