title: Could not generate DH keypair
body: <p>We recently moved our code from Java 5 to Java 7, Tomcat 6 to Tomcat 7 and Spring 2.5 to Spring 4.0.6. All of this together. Unix servers were upgraded as well in Memory and disc space. 
  But since release we are getting below error in Production when batch job sends an email. We are not really sure what is causing this error. I see some other posts like </p>
  
  <p><a href="https://stackoverflow.com/questions/23784016/dh-keypair-exception-in-salesforce">DH keypair exception in salesforce</a></p>
  
  <p><a href="https://stackoverflow.com/questions/10687200/java-7-and-could-not-generate-dh-keypair">Java 7 and Could not generate DH keypair</a></p>
  
  <p><a href="https://stackoverflow.com/questions/14253039/is-there-a-workaround-for-java-lang-runtimeexception-could-not-generate-dh-key">Is there a workaround for: java.lang.RuntimeException: Could not generate DH keypair</a></p>
  
  <p><a href="https://stackoverflow.com/questions/23559000/could-not-generate-dh-keypair-from-proxy-server">Could not generate DH keypair from proxy server</a></p>
  
  <p>But they are not not helping. Can someone please explain in easy language what is causing this issue.</p>
  
  <pre><code>org.springframework.mail.MailSendException: Mail server connection failed; nested exception is javax.mail.MessagingException: Exception reading response;
    nested exception is:
          javax.net.ssl.SSLException: java.lang.RuntimeException: Could not generate DH keypair. Failed messages: javax.mail.MessagingException: Exception reading r
  esponse;
    nested exception is:
          javax.net.ssl.SSLException: java.lang.RuntimeException: Could not generate DH keypair; message exception details (1) are:
  Failed message 1:
  javax.mail.MessagingException: Exception reading response;
    nested exception is:
          javax.net.ssl.SSLException: java.lang.RuntimeException: Could not generate DH keypair
          at com.sun.mail.smtp.SMTPTransport.readServerResponse(SMTPTransport.java:1611)
          at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1369)
          at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:412)
          at javax.mail.Service.connect(Service.java:288)
          at org.springframework.mail.javamail.JavaMailSenderImpl.doSend(JavaMailSenderImpl.java:397)
          at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:346)
          at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:363)
          at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:351)
          at xxx.AbstractEmailServices.sendSingleEmail(AbstractEmailServices.java:281)
          at xxx.EmailServices.sendEmail(EmailServices.java:87)
          at xxx.EmailHelper.sendEmail(EmailHelper.java:60)
          at xxx.EmailHelper.sendEmail(EmailHelper.java:47)
          at xxx.CSVJobListener.afterJob(CSVJobListener.java:68)
          at org.springframework.batch.core.listener.CompositeJobExecutionListener.afterJob(CompositeJobExecutionListener.java:60)
          at org.springframework.batch.core.job.AbstractJob.execute(AbstractJob.java:343)
          at org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run(SimpleJobLauncher.java:134)
          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
          at java.lang.Thread.run(Thread.java:745)
  Caused by: javax.net.ssl.SSLException: java.lang.RuntimeException: Could not generate DH keypair
          at sun.security.ssl.Alerts.getSSLException(Alerts.java:208)
  </code></pre>