rubenlagus / TelegramBots

Java library to create bots using Telegram Bots API
https://telegram.me/JavaBotsApi
MIT License
4.78k stars 1.22k forks source link

Cannot start bot because "the trustAnchors parameter must be non-empty" #453

Closed peteh closed 6 years ago

peteh commented 6 years ago

I'm running on Ubuntu 18.04 and wanted to create a small Telegram bot.

I added the jars with dependencies to my eclipse project and tried the tutorial code from here (with my own bot name and api key): https://gist.github.com/Clevero/f32b35139f6c900cdc01

This one ends up in a bunch of exceptions but I cannot figure out the root issue:

org.telegram.telegrambots.exceptions.TelegramApiRequestException: Error executing setWebook method at org.telegram.telegrambots.bots.TelegramLongPollingBot.clearWebhook(TelegramLongPollingBot.java:55) at org.telegram.telegrambots.TelegramBotsApi.registerBot(TelegramBotsApi.java:120) at com.kthxbye.us.homebot.Main.main(Main.java:15) Caused by: 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:1964) at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1921) at sun.security.ssl.SSLSocketImpl.handleException(SSLSocketImpl.java:1904) at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1420) at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1397) at org.apache.http.conn.ssl.SSLConnectionSocketFactory.createLayeredSocket(SSLConnectionSocketFactory.java:396) at org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:355) at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:142) at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:359) at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:381) at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:237) at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185) at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89) at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:111) at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185) at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83) at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:108) at org.telegram.telegrambots.bots.TelegramLongPollingBot.clearWebhook(TelegramLongPollingBot.java:43) ... 2 more Caused by: java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty at sun.security.validator.PKIXValidator.(PKIXValidator.java:91) 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:1596) at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:216) at sun.security.ssl.Handshaker.processLoop(Handshaker.java:1052) at sun.security.ssl.Handshaker.process_record(Handshaker.java:987) at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1072) at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1385) at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1413) ... 16 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:89) ... 28 more

rubenlagus commented 6 years ago

It looks like a problem with the truststore, maybe this can help to set it up: http://architecturalatrocities.com/post/19073788679/fixing-the-trustanchors-problem-when-running

peteh commented 6 years ago

Thx, I could solve it by purging openjdk-* and reinstalling openjdk 11. Then the problems went away. My bot now works.

rubenlagus commented 6 years ago

Ok, closing it ;)