Skip to content

Commit 8e39adf

Browse files
authored
Merge pull request #200 from Bolukan/master
Add Root Certificate
2 parents 2a24ee9 + 63ed4a5 commit 8e39adf

File tree

3 files changed

+115
-13
lines changed

3 files changed

+115
-13
lines changed

src/TelegramCertificate.h

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
/*
2+
The root certificate will be valid for years:
3+
*.telegram.org ->
4+
Go Daddy Secure Certificate Authority - G2 ->
5+
Go Daddy Root Certificate Authority - G2
6+
*/
7+
8+
// Go Daddy Root Certificate Authority - G2
9+
const char TELEGRAM_CERTIFICATE_ROOT[] = R"=EOF=(
10+
-----BEGIN CERTIFICATE-----
11+
MIIDxTCCAq2gAwIBAgIBADANBgkqhkiG9w0BAQsFADCBgzELMAkGA1UEBhMCVVMx
12+
EDAOBgNVBAgTB0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxGjAYBgNVBAoT
13+
EUdvRGFkZHkuY29tLCBJbmMuMTEwLwYDVQQDEyhHbyBEYWRkeSBSb290IENlcnRp
14+
ZmljYXRlIEF1dGhvcml0eSAtIEcyMB4XDTA5MDkwMTAwMDAwMFoXDTM3MTIzMTIz
15+
NTk1OVowgYMxCzAJBgNVBAYTAlVTMRAwDgYDVQQIEwdBcml6b25hMRMwEQYDVQQH
16+
EwpTY290dHNkYWxlMRowGAYDVQQKExFHb0RhZGR5LmNvbSwgSW5jLjExMC8GA1UE
17+
AxMoR28gRGFkZHkgUm9vdCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkgLSBHMjCCASIw
18+
DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL9xYgjx+lk09xvJGKP3gElY6SKD
19+
E6bFIEMBO4Tx5oVJnyfq9oQbTqC023CYxzIBsQU+B07u9PpPL1kwIuerGVZr4oAH
20+
/PMWdYA5UXvl+TW2dE6pjYIT5LY/qQOD+qK+ihVqf94Lw7YZFAXK6sOoBJQ7Rnwy
21+
DfMAZiLIjWltNowRGLfTshxgtDj6AozO091GB94KPutdfMh8+7ArU6SSYmlRJQVh
22+
GkSBjCypQ5Yj36w6gZoOKcUcqeldHraenjAKOc7xiID7S13MMuyFYkMlNAJWJwGR
23+
tDtwKj9useiciAF9n9T521NtYJ2/LOdYq7hfRvzOxBsDPAnrSTFcaUaz4EcCAwEA
24+
AaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYE
25+
FDqahQcQZyi27/a9BUFuIMGU2g/eMA0GCSqGSIb3DQEBCwUAA4IBAQCZ21151fmX
26+
WWcDYfF+OwYxdS2hII5PZYe096acvNjpL9DbWu7PdIxztDhC2gV7+AJ1uP2lsdeu
27+
9tfeE8tTEH6KRtGX+rcuKxGrkLAngPnon1rpN5+r5N9ss4UXnT3ZJE95kTXWXwTr
28+
gIOrmgIttRD02JDHBHNA7XIloKmf7J6raBKZV8aPEjoJpL1E/QYVN8Gb5DKj7Tjo
29+
2GTzLH4U/ALqn83/B2gX2yKQOC16jdFU8WnjXzPKej17CuPKf1855eJ1usV2GDPO
30+
LPAvTK33sefOT6jEm0pUBsV/fdUID+Ic/n4XuKxe9tQWskMJDE32p2u0mYRlynqI
31+
4uJEvlz36hz1
32+
-----END CERTIFICATE-----
33+
)=EOF=";
34+
35+
/*
36+
Certificate:
37+
Data:
38+
Version: 3 (0x2)
39+
Serial Number: 0 (0x0)
40+
Signature Algorithm: sha256WithRSAEncryption
41+
Issuer:
42+
commonName = Go Daddy Root Certificate Authority - G2
43+
organizationName = GoDaddy.com, Inc.
44+
localityName = Scottsdale
45+
stateOrProvinceName = Arizona
46+
countryName = US
47+
Validity
48+
Not Before: Sep 1 00:00:00 2009 GMT
49+
Not After : Dec 31 23:59:59 2037 GMT
50+
Subject:
51+
commonName = Go Daddy Root Certificate Authority - G2
52+
organizationName = GoDaddy.com, Inc.
53+
localityName = Scottsdale
54+
stateOrProvinceName = Arizona
55+
countryName = US
56+
Subject Public Key Info:
57+
Public Key Algorithm: rsaEncryption
58+
Public-Key: (2048 bit)
59+
Modulus:
60+
00:bf:71:62:08:f1:fa:59:34:f7:1b:c9:18:a3:f7:
61+
80:49:58:e9:22:83:13:a6:c5:20:43:01:3b:84:f1:
62+
e6:85:49:9f:27:ea:f6:84:1b:4e:a0:b4:db:70:98:
63+
c7:32:01:b1:05:3e:07:4e:ee:f4:fa:4f:2f:59:30:
64+
22:e7:ab:19:56:6b:e2:80:07:fc:f3:16:75:80:39:
65+
51:7b:e5:f9:35:b6:74:4e:a9:8d:82:13:e4:b6:3f:
66+
a9:03:83:fa:a2:be:8a:15:6a:7f:de:0b:c3:b6:19:
67+
14:05:ca:ea:c3:a8:04:94:3b:46:7c:32:0d:f3:00:
68+
66:22:c8:8d:69:6d:36:8c:11:18:b7:d3:b2:1c:60:
69+
b4:38:fa:02:8c:ce:d3:dd:46:07:de:0a:3e:eb:5d:
70+
7c:c8:7c:fb:b0:2b:53:a4:92:62:69:51:25:05:61:
71+
1a:44:81:8c:2c:a9:43:96:23:df:ac:3a:81:9a:0e:
72+
29:c5:1c:a9:e9:5d:1e:b6:9e:9e:30:0a:39:ce:f1:
73+
88:80:fb:4b:5d:cc:32:ec:85:62:43:25:34:02:56:
74+
27:01:91:b4:3b:70:2a:3f:6e:b1:e8:9c:88:01:7d:
75+
9f:d4:f9:db:53:6d:60:9d:bf:2c:e7:58:ab:b8:5f:
76+
46:fc:ce:c4:1b:03:3c:09:eb:49:31:5c:69:46:b3:
77+
e0:47
78+
Exponent: 65537 (0x10001)
79+
X509v3 extensions:
80+
X509v3 Basic Constraints: critical
81+
CA:TRUE
82+
X509v3 Key Usage: critical
83+
Certificate Sign, CRL Sign
84+
X509v3 Subject Key Identifier:
85+
3A:9A:85:07:10:67:28:B6:EF:F6:BD:05:41:6E:20:C1:94:DA:0F:DE
86+
Signature Algorithm: sha256WithRSAEncryption
87+
99:db:5d:79:d5:f9:97:59:67:03:61:f1:7e:3b:06:31:75:2d:
88+
a1:20:8e:4f:65:87:b4:f7:a6:9c:bc:d8:e9:2f:d0:db:5a:ee:
89+
cf:74:8c:73:b4:38:42:da:05:7b:f8:02:75:b8:fd:a5:b1:d7:
90+
ae:f6:d7:de:13:cb:53:10:7e:8a:46:d1:97:fa:b7:2e:2b:11:
91+
ab:90:b0:27:80:f9:e8:9f:5a:e9:37:9f:ab:e4:df:6c:b3:85:
92+
17:9d:3d:d9:24:4f:79:91:35:d6:5f:04:eb:80:83:ab:9a:02:
93+
2d:b5:10:f4:d8:90:c7:04:73:40:ed:72:25:a0:a9:9f:ec:9e:
94+
ab:68:12:99:57:c6:8f:12:3a:09:a4:bd:44:fd:06:15:37:c1:
95+
9b:e4:32:a3:ed:38:e8:d8:64:f3:2c:7e:14:fc:02:ea:9f:cd:
96+
ff:07:68:17:db:22:90:38:2d:7a:8d:d1:54:f1:69:e3:5f:33:
97+
ca:7a:3d:7b:0a:e3:ca:7f:5f:39:e5:e2:75:ba:c5:76:18:33:
98+
ce:2c:f0:2f:4c:ad:f7:b1:e7:ce:4f:a8:c4:9b:4a:54:06:c5:
99+
7f:7d:d5:08:0f:e2:1c:fe:7e:17:b8:ac:5e:f6:d4:16:b2:43:
100+
09:0c:4d:f6:a7:6b:b4:99:84:65:ca:7a:88:e2:e2:44:be:5c:
101+
f7:ea:1c:f5
102+
*/

src/UniversalTelegramBot.cpp

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ String UniversalTelegramBot::buildCommand(const String& cmd) {
6464

6565
String UniversalTelegramBot::sendGetToTelegram(const String& command) {
6666
String body, headers;
67-
bool avail;
6867

6968
// Connect with api.telegram.org if not already connected
7069
if (!client->connected()) {
@@ -99,7 +98,7 @@ String UniversalTelegramBot::sendGetToTelegram(const String& command) {
9998

10099
bool UniversalTelegramBot::readHTTPAnswer(String &body, String &headers) {
101100
int ch_count = 0;
102-
long now = millis();
101+
unsigned long now = millis();
103102
bool finishedHeaders = false;
104103
bool currentLineIsBlank = true;
105104
bool responseReceived = false;
@@ -268,7 +267,7 @@ String UniversalTelegramBot::sendMultipartFormDataToTelegram(
268267
#endif
269268
byte buffer[512];
270269
int count = 0;
271-
char ch;
270+
272271
while (moreDataAvailableCallback()) {
273272
buffer[count] = getNextByteCallback();
274273
count++;
@@ -335,7 +334,7 @@ bool UniversalTelegramBot::setMyCommands(const String& commandArray) {
335334
#endif // defined(_debug)
336335
unsigned long sttime = millis();
337336

338-
while (millis() < sttime + 8000ul) { // loop for a while to send the message
337+
while (millis() - sttime < 8000ul) { // loop for a while to send the message
339338
response = sendPostToTelegram(BOT_CMD("setMyCommands"), payload.as<JsonObject>());
340339
#ifdef _debug
341340
Serial.println("setMyCommands response" + response);
@@ -533,10 +532,10 @@ bool UniversalTelegramBot::sendSimpleMessage(const String& chat_id, const String
533532
#ifdef TELEGRAM_DEBUG
534533
Serial.println(F("sendSimpleMessage: SEND Simple Message"));
535534
#endif
536-
long sttime = millis();
535+
unsigned long sttime = millis();
537536

538537
if (text != "") {
539-
while (millis() < sttime + 8000) { // loop for a while to send the message
538+
while (millis() - sttime < 8000ul) { // loop for a while to send the message
540539
String command = BOT_CMD("sendMessage?chat_id=");
541540
command += chat_id;
542541
command += F("&text=");
@@ -626,10 +625,10 @@ bool UniversalTelegramBot::sendPostMessage(JsonObject payload) {
626625
serializeJson(payload, Serial);
627626
Serial.println();
628627
#endif
629-
long sttime = millis();
628+
unsigned long sttime = millis();
630629

631630
if (payload.containsKey("text")) {
632-
while (millis() < sttime + 8000) { // loop for a while to send the message
631+
while (millis() - sttime < 8000ul) { // loop for a while to send the message
633632
String response = sendPostToTelegram(BOT_CMD("sendMessage"), payload);
634633
#ifdef TELEGRAM_DEBUG
635634
Serial.println(response);
@@ -650,10 +649,10 @@ String UniversalTelegramBot::sendPostPhoto(JsonObject payload) {
650649
#ifdef TELEGRAM_DEBUG
651650
Serial.println(F("sendPostPhoto: SEND Post Photo"));
652651
#endif
653-
long sttime = millis();
652+
unsigned long sttime = millis();
654653

655654
if (payload.containsKey("photo")) {
656-
while (millis() < sttime + 8000) { // loop for a while to send the message
655+
while (millis() - sttime < 8000ul) { // loop for a while to send the message
657656
response = sendPostToTelegram(BOT_CMD("sendPhoto"), payload);
658657
#ifdef TELEGRAM_DEBUG
659658
Serial.println(response);
@@ -733,10 +732,10 @@ bool UniversalTelegramBot::sendChatAction(const String& chat_id, const String& t
733732
#ifdef TELEGRAM_DEBUG
734733
Serial.println(F("SEND Chat Action Message"));
735734
#endif
736-
long sttime = millis();
735+
unsigned long sttime = millis();
737736

738737
if (text != "") {
739-
while (millis() < sttime + 8000) { // loop for a while to send the message
738+
while (millis() - sttime < 8000ul) { // loop for a while to send the message
740739
String command = BOT_CMD("sendChatAction?chat_id=");
741740
command += chat_id;
742741
command += F("&action=");

src/UniversalTelegramBot.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2828
#include <Arduino.h>
2929
#include <ArduinoJson.h>
3030
#include <Client.h>
31+
#include <TelegramCertificate.h>
3132

3233
#define TELEGRAM_HOST "api.telegram.org"
3334
#define TELEGRAM_SSL_PORT 443
@@ -121,7 +122,7 @@ class UniversalTelegramBot {
121122
String name;
122123
String userName;
123124
int longPoll = 0;
124-
int waitForResponse = 1500;
125+
unsigned int waitForResponse = 1500;
125126
int _lastError;
126127
int last_sent_message_id = 0;
127128
int maxMessageLength = 1500;

0 commit comments

Comments
 (0)