SSL error: 0A00010B:SSL routines::wrong version number
See original GitHub issueHello. My sbt
scalaVersion := "2.12.4"
libraryDependencies ++= Seq(
"ch.qos.logback" % "logback-classic" % "1.2.3",
"org.scala-lang" % "scala-library" % "2.12.4",
"com.typesafe" % "config" % "1.3.4",
"com.bot4s" %% "telegram-core" % "5.4.2",
"com.bot4s" %% "telegram-akka" % "5.4.2",
"com.github.jnr" % "jnr-ffi" % "2.2.12",
"com.github.oshi" % "oshi-core" % "6.1.6"
)
jdk-11.0.13\bin === step 1 === 1.2.3.4 is my static ip
C:\jdk-11.0.13\bin>keytool -genkey -keyalg RSA -alias mts -keystore mts.jks -storepass 333333 -validity 360 -keysize 2048
What is your first and last name?
[Unknown]: 1.2.3.4
What is the name of your organizational unit?
[Unknown]: mts
What is the name of your organization?
[Unknown]: mts
What is the name of your City or Locality?
[Unknown]: PERM
What is the name of your State or Province?
[Unknown]: PERM
What is the two-letter country code for this unit?
[Unknown]: RU
Is CN=1.2.3.4, OU=mts, O=mts, L=PERM, ST=PERM, C=RU correct?
[no]: yes
=== step 2 ===
C:\jdk-11.0.13\bin>keytool -importkeystore -srckeystore mts.jks -destkeystore mts.p12 -srcstoretype jks -deststoretype pkcs12
Importing keystore mts.jks to mts.p12...
Enter destination keystore password:
Re-enter new password:
Enter source keystore password:
Entry for alias mts successfully imported.
Import command completed: 1 entries successfully imported, 0 entries failed or cancelled
=== step 3 ===
copy file mts.p12 into C:\openssl3\bin
cd C:\openssl3\bin
C:\openssl3\bin>openssl version
OpenSSL 3.0.3 3 May 2022 (Library: OpenSSL 3.0.3 3 May 2022)
C:\openssl3\bin>openssl pkcs12 -in mts.p12 -out mts.pem -passin pass:333333
Next, I left only this content in mts.pem
-----BEGIN CERTIFICATE-----
MIIDWzCCAkOgAwIBAgIEUIe/jzANBgkqhkiG9w0BAQsFADBeMQswCQYDVQQGEwJS
........
BOujl3TIbWK/kMfMD9Ggby4j3rU1PDcZEdlt7ZOXm4vlZ0eyG85zbmpOsQYUhZ4=
-----END CERTIFICATE-----
Copy both files mts.pem and mts.p12 into resource of my project.
My config
teleg {
token="886094130:AAENizOGvqrl7vrLVeOZwKfJdIJyQEU_xxx"
webhook_port=8443
webhookUrl="https://1.2.3.4:8443"
keyStorePassword=333333
pubcertpath="E:\\PROJECTS\\mtspredbot\\src\\main\\resources\\mts.pem"
p12certpath="E:\\PROJECTS\\mtspredbot\\src\\main\\resources\\mts.p12"
}
In my class I have this parts of code
class telegBotWH(log :org.slf4j.Logger,
config :Config)
extends AkkaTelegramBot
with Webhook
with CommonFuncs
with Commands[Future]
{
val confPrefix :String = "teleg."
val port :Int = config.getInt(confPrefix+"webhook_port")
val webhookUrl = config.getString(confPrefix+"webhookUrl")
log.info(" webhookUrl="+webhookUrl+" port="+port)
val certPathStr :String = config.getString(confPrefix+"pubcertpath")
log.info("Certificate Path ="+certPathStr)
override def certificate: Option[InputFile] = Some(
InputFile(new File(certPathStr).toPath)
)
override def receiveMessage(msg: Message): Future[Unit] = {
log.info("receiveMessage method!!!")
msg.text.fold(Future.successful(())) {
text =>
log.info(s"receiveMessage text OK =$text")
Future.successful()
}
}
val keystorePassword :Array[Char] = config.getString(confPrefix+"keyStorePassword").toCharArray
override val interfaceIp: String = "0.0.0.0"
// Set custom context.
Http().setDefaultServerHttpContext(httpsContext(keystorePassword))
def httpsContext(keystorePassword : Array[Char]): HttpsConnectionContext = {
// Manual HTTPS configuration
val password: Array[Char] = keystorePassword
val ks: KeyStore = KeyStore.getInstance("PKCS12")
val keystore: InputStream = new FileInputStream(config.getString(confPrefix+"p12certpath"))
require(keystore != null, " - Keystore required!")
ks.load(keystore, password)
val keyManagerFactory: KeyManagerFactory = KeyManagerFactory.getInstance("SunX509")
keyManagerFactory.init(ks, password)
val tmf: TrustManagerFactory = TrustManagerFactory.getInstance("SunX509")
tmf.init(ks)
val sslContext: SSLContext = SSLContext.getInstance("TLS")
sslContext.init(keyManagerFactory.getKeyManagers, tmf.getTrustManagers, new SecureRandom)
val https: HttpsConnectionContext = ConnectionContext.httpsClient(sslContext)
https
}
log.info("AkkaHttpClient - " + config.getString(confPrefix+"token"))
//override
val client = new AkkaHttpClient(config.getString(confPrefix+"token"))
...
When I run the bot in IDEA
val bot = new telegBotWH(log, config)
val eol = bot.run
Have output:
C:\Users\yakushev\.jdks\openjdk-15.0.2\bin\java.exe "
...
...
mtspredbot.Main src\main\resources\control.conf
13:05:35.975 [main] INFO mtspredbot.Main$ - ~~~~~~~~~~~~~~~~~~~~~~~~ BEGIN TELEGRAM BOT ~~~~~~~~~~~~~~~~~~~~~~~~
13:05:35.992 [main] INFO mtspredbot.Main$ - There is external config file, path=E:\PROJECTS\mtspredbot\src\main\resources\control.conf
13:05:36.966 [main] INFO mtspredbot.Main$ - webhookUrl=https://1.2.3.4:8443 port=8443
13:05:36.966 [main] INFO mtspredbot.Main$ - Certificate Path =E:\PROJECTS\mtspredbot\src\main\resources\mts.pem
13:05:37.649 [main] INFO mtspredbot.Main$ - AkkaHttpClient - 886094130:AAENizOGvqrl7vrLVeOZwKfJdIJyQEU_xxx
13:05:38.444 [main] DEBUG o.h.common.AbstractCentralProcessor - Oracle MXBean detected.
13:05:38.553 [main] DEBUG o.d.windows.PerfCounterWildcardQuery - Localized Processor to Процессор
13:05:38.733 [main] DEBUG o.h.p.w.WindowsCentralProcessor - Initialized Processor
13:05:38.734 [main] DEBUG o.h.common.AbstractCentralProcessor - Oracle MXBean detected.
13:05:38.756 [main] DEBUG o.d.windows.PerfCounterWildcardQuery - Localized Processor to Процессор
13:05:38.797 [main] DEBUG o.h.p.w.WindowsCentralProcessor - Initialized Processor
13:05:38.804 [main] TRACE c.b.telegram.clients.AkkaHttpClient - REQUEST edb74b8e-4593-4da9-af16-08ebefa833e3 SetWebhook(https://1.2.3.4:8443,Some(Path(E:\PROJECTS\mtspredbot\src\main\resources\mts.pem)),None,None)
Press [ENTER] to shutdown the bot, it may take a few seconds...
13:05:40.868 [scala-execution-context-global-38] TRACE c.b.telegram.clients.AkkaHttpClient - RESPONSE edb74b8e-4593-4da9-af16-08ebefa833e3 true
13:05:41.035 [scala-execution-context-global-38] INFO mtspredbot.telegBotWH - Listening on 0.0.0.0:8443
[WARN] [06/22/2022 13:05:41.873] [default-akka.actor.default-dispatcher-7] [akka.actor.ActorSystemImpl(default)] Illegal request, responding with status '400 Bad Request': Unsupported HTTP method: The HTTP method started with 0x16 rather than any known HTTP method. Perhaps this was an HTTPS request sent to an HTTP endpoint?
[WARN] [06/22/2022 13:05:42.310] [default-akka.actor.default-dispatcher-21] [akka.actor.ActorSystemImpl(default)] Illegal request, responding with status '400 Bad Request': Unsupported HTTP method: The HTTP method started with 0x16 rather than any known HTTP method. Perhaps this was an HTTPS request sent to an HTTP endpoint?
[WARN] [06/22/2022 13:05:44.296] [default-akka.actor.default-dispatcher-18] [akka.actor.ActorSystemImpl(default)] Illegal request, responding with status '400 Bad Request': Unsupported HTTP method: The HTTP method started with 0x16 rather than any known HTTP method. Perhaps this was an HTTPS request sent to an HTTP endpoint?
...
each 1,2 seconds I have new message about Bad Request
...
If I check getWebhookInfo
https://api.telegram.org/bot886094130:AAENizOGvqrl7vrLVeOZwKfJdIJyQEU_xxx/getWebhookInfo
output:
{"ok":true,"result":{"url":"https://1.2.3.4:8443","has_custom_certificate":true,"pending_update_count":3,"last_error_date":1655885301,"last_error_message":"SSL error {error:0A00010B:SSL routines::wrong version number}","max_connections":40,"ip_address":"1.2.3.4","allowed_updates":["message","callback_query"]}}
In telegram app I made chat with my bot and I see that he is receiving messages. But there is no reaction from my code (onCommand). Only a lot of Illegal request, responding with status ‘400 Bad Request’: …
Could you help me please investigate this problem?
Issue Analytics
- State:
- Created a year ago
- Comments:10 (10 by maintainers)
Top Results From Across the Web
curl: (35) error:1408F10B:SSL routines:ssl3_get_record:wrong ...
The curl is not able to connect to server so it shows wrong version number. Set proxy by opening subl ~/.curlrc or use...
Read more >Unable to establish SSL connection: wrong version number
However, I am running into another problem with connecting to the website itself. The website is returning a ERR_SSL_PROTOCOL_ERROR everytime I ...
Read more >curl: (35) error:0A00010B:SSL routines::wrong version ...
This output is confusing. Are you saying it works sometimes and sometimes not? Or are you saying that it used to work but...
Read more >Error:1408f10b:ssl routines:ssl3_get_record:wrong version ...
First, ensure the domain is pointing to the correct server. · Then, check the configuration file for our websites is enabled in Apache....
Read more >how to solve SSL3_GET_RECORD:wrong version number ...
If I try -no_tls1, theerror has printed as below. > error:14077102:SSL routines:SSL23_GET_SERVER_HELLO:unsupported > protocol:s23_clnt.c:697: [.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I have merged PR.
Yes there is a telegram channel, even if pretty inactive, you can always post there: https://t.me/bot4s I don’t use IntelliJ to run my tests, however it should work out of the box…
To run tests I use
Which will run all tests.
To run the example it’s a bit more complex, but what I use is
Which drops you into a console with all the classes loaded on the class path, and you can then do a
To start a specific bot. For cats parts it is similar:
You can check the
Launch.scala
to find which examples are availableAnd for monix