Salve, salve Jedis do GUJ.
Mais uma vez, venho em busca de socorro!
Estou configurando o SMTP da minha aplicação como o GMail (usando o Spring), mas estou obtendo o seguinte erro:12:10:49,308 INFO [STDOUT] DEBUG: JavaMail version 1.4.1ea-SNAPSHOT
12:10:49,309 INFO [STDOUT] DEBUG: not loading file: /usr/lib/jvm/java-6-openjdk/jre/lib/javamail.providers
12:10:49,309 INFO [STDOUT] DEBUG: java.io.FileNotFoundException: /usr/lib/jvm/java-6-openjdk/jre/lib/javamail.providers (No such file or directory)
12:10:49,312 INFO [STDOUT] DEBUG: !anyLoaded
12:10:49,313 INFO [STDOUT] DEBUG: not loading resource: /META-INF/javamail.providers
12:10:49,315 INFO [STDOUT] DEBUG: successfully loaded resource: /META-INF/javamail.default.providers
12:10:49,316 INFO [STDOUT] DEBUG: Tables of loaded providers
12:10:49,316 INFO [STDOUT] DEBUG: Providers Listed By Class Name: {com.sun.mail.smtp.SMTPSSLTransport=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsystems, Inc], com.sun.mail.smtp.SMTPTransport=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc], com.sun.mail.imap.IMAPSSLStore=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun Microsystems, Inc], com.sun.mail.pop3.POP3SSLStore=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Sun Microsystems, Inc], com.sun.mail.imap.IMAPStore=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc], com.sun.mail.pop3.POP3Store=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun Microsystems, Inc]}
12:10:49,316 INFO [STDOUT] DEBUG: Providers Listed By Protocol: {imaps=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun Microsystems, Inc], imap=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc], smtps=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsystems, Inc], pop3=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun Microsystems, Inc], pop3s=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Sun Microsystems, Inc], smtp=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]}
12:10:49,316 INFO [STDOUT] DEBUG: successfully loaded resource: /META-INF/javamail.default.address.map
12:10:49,322 INFO [STDOUT] DEBUG: !anyLoaded
12:10:49,323 INFO [STDOUT] DEBUG: not loading resource: /META-INF/javamail.address.map
12:10:49,323 INFO [STDOUT] DEBUG: not loading file: /usr/lib/jvm/java-6-openjdk/jre/lib/javamail.address.map
12:10:49,323 INFO [STDOUT] DEBUG: java.io.FileNotFoundException: /usr/lib/jvm/java-6-openjdk/jre/lib/javamail.address.map (No such file or directory)
12:10:49,346 INFO [STDOUT] DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]
12:10:49,359 INFO [STDOUT] DEBUG SMTP: useEhlo true, useAuth true
12:10:49,359 INFO [STDOUT] DEBUG SMTP: trying to connect to host "smtp.gmail.com", port 465, isSSL false
12:10:49,507 INFO [STDOUT] DEBUG SMTP: exception reading response: javax.net.ssl.SSLException: java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty
12:10:49,508 ERROR [STDERR] 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: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty
Contexto:
- Servidor Linux
- java-6-openjdk
Detalhes:
A configuração para seu uso através do Spring é:
no AplicationContext.xml: <bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
<property name="defaultEncoding" value="UTF-8"/>
<property name="host" value="smtp.gmail.com" />
<property name="port" value="465" />
<property name="username" value="noreply@xxx.com" />
<property name="password" value="xxx" />
<property name="javaMailProperties">
<props>
<prop key="mail.debug">true</prop>
<prop key="mail.smtp.auth">true</prop>
<prop key="mail.smtp.socketFactory.port">465</prop>
<prop key="mail.smtp.socketFactory.class">javax.net.ssl.SSLSocketFactory</prop>
<prop key="mail.smtp.socketFactory.fallback">false</prop>
<prop key="mail.smtps.starttls.enable">true</prop>
</props>
</property>
</bean>
Pesquisando sobre esse erro na net, encontrei um link interessante que explica com configurar o GMail no JIRA: http://confluence.atlassian.com/display/JIRA/Using+Gmail+as+a+JIRA+Mail+Server.
Lá é explicado que é necessário importar o certificado SSL do GMail. Para tal é sugerida a instalação do OpenSSL.
Me loguei como root, fiz a instalação e criei o certificado, seguindo os passos indicados no artigo.
Em seguida, no passo 4, é instruído para importar o certificado utilizando a ferramenta keytool, através do seguinte comando (como sou su, ignoro o sudo): keytool -import -alias smtp.gmail.com -keystore $JAVA_HOME/jre/lib/security/cacerts -file /path/to/gmail.cert
Entretanto, com esse comando obtenho a seguinte saída: [code]Owner: CN=smtp.gmail.com, O=Google Inc, L=Mountain View, ST=California, C=US
Issuer: CN=Google Internet Authority, O=Google Inc, C=US
Serial number: 68cf6e310003000022ad
Valid from: Wed Feb 16 02:38:09 BRST 2011 until: Thu Feb 16 02:48:09 BRST 2012
Certificate fingerprints:
MD5: 02:4C:12:F3:37:1F:0C:C1:EB:10:4B:92:F7:F1:E0:DF
SHA1: DB:A0:2A:07:00:F9:E3:23:7D:07:E7:52:3C:95:9D:E6:7E:12:54:3F
Signature algorithm name: SHA1withRSA
Version: 3
Extensions:
#1: ObjectId: 2.5.29.14 Criticality=false
SubjectKeyIdentifier [
KeyIdentifier [
0000: 0A B2 D4 CC 51 31 DC 40 4A 44 A6 06 97 B9 55 57 …Q1.@JD…UW
0010: 25 E2 07 C6 %…
]
]
#2: ObjectId: 1.3.6.1.5.5.7.1.1 Criticality=false
AuthorityInfoAccess [
[accessMethod: 1.3.6.1.5.5.7.48.2
accessLocation: URIName: http://www.gstatic.com/GoogleInternetAuthority/GoogleInternetAuthority.crt]
]
#3: ObjectId: 1.3.6.1.4.1.311.20.2 Criticality=false
#4: ObjectId: 2.5.29.31 Criticality=false
CRLDistributionPoints [
[DistributionPoint:
[URIName: http://www.gstatic.com/GoogleInternetAuthority/GoogleInternetAuthority.crl]
]]
#5: ObjectId: 2.5.29.35 Criticality=false
AuthorityKeyIdentifier [
KeyIdentifier [
0000: BF C0 30 EB F5 43 11 3E 67 BA 9E 91 FB FC 6A DA …0…C.>g…j.
0010: E3 6B 12 24 .k.$
]
]
Trust this certificate? [no]: yes
Certificate was added to keystore
keytool error: java.io.FileNotFoundException: /usr/lib/jvm/java-6-openjdk/jre/lib/security/cacerts (No such file or directory)[/code] Ou seja, após a confirmação de que o certificado é confiável, é disparado uma exception informando que “/usr/lib/jvm/java-6-openjdk/jre/lib/security/cacerts” (No such file or directory).
Porém o arquivo existe e está no path indicado.
Alguém já passou por esse problema e tem alguma idéia de como resolver?
Será algum problema de permissão?
Agradeço desde já por qualquer ajuda, dica, reza, simpatia ou macumba!
Valeu turma.
PS: Atualizei pra um trace mais completo.