Unihedro / JavaBot

Java based chat bot that runs in Java room of Stack Overflow Chat.
Apache License 2.0
15 stars 4 forks source link

JavaBot does not log in! #57

Closed ByteCommander closed 9 years ago

ByteCommander commented 9 years ago

Following error message:


$ java -jar javabot.jar
Picked up JAVA_TOOL_OPTIONS: -javaagent:/usr/share/java/jayatanaag.jar 
May 03, 2015 2:32:00 PM com.gmail.inverseconduit.BotConfig 
INFO: Setting loginEmail to mymailaddress@example.de
May 03, 2015 2:32:00 PM com.gmail.inverseconduit.BotConfig 
INFO: Setting password
May 03, 2015 2:32:00 PM com.gmail.inverseconduit.BotConfig 
INFO: Setting trigger to !!
May 03, 2015 2:32:00 PM com.gmail.inverseconduit.BotConfig 
INFO: Setting javadocs dir to javadocs
May 03, 2015 2:32:00 PM com.gmail.inverseconduit.BotConfig 
INFO: Setting rooms to [1]
May 03, 2015 2:32:04 PM com.gmail.inverseconduit.chat.StackExchangeChat getLoginPage
SEVERE: Couldn't fetch Login Page / IOException when logging in
javax.net.ssl.SSLException: java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty
    at sun.security.ssl.Alerts.getSSLException(Alerts.java:208)
    at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1937)
    at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1894)
    at sun.security.ssl.SSLSocketImpl.handleException(SSLSocketImpl.java:1877)
    at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1398)
    at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1375)
    at org.apache.http.conn.ssl.SSLConnectionSocketFactory.createLayeredSocket(SSLConnectionSocketFactory.java:275)
    at org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:254)
    at com.gargoylesoftware.htmlunit.HtmlUnitSSLConnectionSocketFactory.connectSocket(HtmlUnitSSLConnectionSocketFactory.java:155)
    at org.apache.http.impl.conn.HttpClientConnectionOperator.connect(HttpClientConnectionOperator.java:123)
    at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:318)
    at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:363)
    at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:219)
    at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:195)
    at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:86)
    at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:108)
    at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:72)
    at com.gargoylesoftware.htmlunit.HttpWebConnection.getResponse(HttpWebConnection.java:178)
    at com.gargoylesoftware.htmlunit.util.WebConnectionWrapper.getResponse(WebConnectionWrapper.java:68)
    at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseFromWebConnection(WebClient.java:1313)
    at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseFromWebConnection(WebClient.java:1371)
    at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseFromWebConnection(WebClient.java:1363)
    at com.gargoylesoftware.htmlunit.WebClient.loadWebResponse(WebClient.java:1230)
    at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:338)
    at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:407)
    at com.gmail.inverseconduit.chat.StackExchangeChat.getLoginPage(StackExchangeChat.java:90)
    at com.gmail.inverseconduit.chat.StackExchangeChat.login(StackExchangeChat.java:62)
    at com.gmail.inverseconduit.Main.main(Main.java:45)
Caused by: java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty
    at sun.security.validator.PKIXValidator.(PKIXValidator.java:90)
    at sun.security.validator.Validator.getInstance(Validator.java:179)
    at sun.security.ssl.X509TrustManagerImpl.getValidator(X509TrustManagerImpl.java:312)
    at sun.security.ssl.X509TrustManagerImpl.checkTrustedInit(X509TrustManagerImpl.java:171)
    at sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:184)
    at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:124)
    at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1460)
    at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:212)
    at sun.security.ssl.Handshaker.processLoop(Handshaker.java:979)
    at sun.security.ssl.Handshaker.process_record(Handshaker.java:914)
    at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1050)
    at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1363)
    at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1391)
    ... 24 more
Caused by: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty
    at java.security.cert.PKIXParameters.setTrustAnchors(PKIXParameters.java:200)
    at java.security.cert.PKIXParameters.(PKIXParameters.java:120)
    at java.security.cert.PKIXBuilderParameters.(PKIXBuilderParameters.java:104)
    at sun.security.validator.PKIXValidator.(PKIXValidator.java:88)
    ... 36 more
May 03, 2015 2:32:04 PM com.gmail.inverseconduit.Main main
SEVERE: Login failed!
Exception in thread "main" java.lang.RuntimeException: Login failure
    at com.gmail.inverseconduit.Main.main(Main.java:47)
Vogel612 commented 9 years ago

Hello @ByteCommander,

From seeing the stacktrace the cause of this seems to be something in the SSL / HTTPS of the login page. Which site (Stackoverflow, Stackexchange or Meta.Stackexchange) are you logging in to?

ByteCommander commented 9 years ago

Hello @Vogel612 ,

thank you for responding that fast.

My bot.properties looks like this:

LOGIN-EMAIL=mymailaddress@example.de
PASSWORD=mypassword
TRIGGER=!!
ROOMS=1

According to the source code in com.gmail.inverseconduit.Main.java at line 45

        if ( !seInterface.login(SESite.STACK_OVERFLOW, config)) {

it logs in to stackoverflow.com

Vogel612 commented 9 years ago

A little investigating on the relevant site reveals:

TLS-Version: 1.2
Used Encryption Algorithm: AES_128_GCM
Used Key-Exchange protocol: ECDHE_RSA

I cannot reproduce this issue locally, though. May I ask what java-version you are using?

ByteCommander commented 9 years ago

@Vogel612 Here you go I use OpenJDK8 on Ubuntu 15.04 32bit, kernel 3.19.0-16-generic

$ java -version
Picked up JAVA_TOOL_OPTIONS: -javaagent:/usr/share/java/jayatanaag.jar 
openjdk version "1.8.0_45-internal"
OpenJDK Runtime Environment (build 1.8.0_45-internal-b14)
OpenJDK Server VM (build 25.45-b02, mixed mode)
fge commented 9 years ago

@ByteCommander do you have jce.jar and jsse.jar in your JRE/JDK install?

ByteCommander commented 9 years ago

@fge Yes, they are listed in eclipse as JRE System Libraries and the files exist on my disk.

Vogel612 commented 9 years ago

There is a completed Ticked to implement the Cipherset which is used here at the OpenJDK Bugtracker, meaning this should be working just fine in OpenJDK 8 (as it does with an Oracle JDK)

Vogel612 commented 9 years ago

After testing and a session with @ByteCommander we found out that the root cause was not javabot code. The error could not be reproduced on my local system.

Especially interesting here is following error (also available in the java room transcript):

[ERROR] Plugin org.apache.maven.plugins:maven-resources-plugin:2.3 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin:jar:2.3: Could not transfer artifact org.apache.maven.plugins:maven-resources-plugin:pom:2.3 from/to central (https://repo.maven.apache.org/maven2): java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException

This means the error occurs whenever an SSL connection is created. The problem thus doesn't lie within javabot code, but in the environment