AmiNadimi
AmiNadimi

Reputation: 5725

Telegram SetWebHook Self Signed Certificate

I'm Trying to Send a Self Signed Certificate To telegram . The Configuration will be done through PostMan And My Bot Server is Ok (tests through getUpdates and action call over ssl connection responded successfully).

Here is what i send to telegram :

api.telegram.org/botMY TOKEN/setWebhook?url=MY SWERVER IP:443/api/webhook

and i DO attach the PUBLICKEY.pem as a binary body to the request.

Here is what i get :

{ "ok": true, "result": true, "description": "Webhook was set" }

the problem is when i check the webHook via getWebHookInfo :

{
  "ok": true,
  "result": {
    "url": "94.183.157.125:443/api/webhook",
    "has_custom_certificate": false,
    "pending_update_count": 5,
    "last_error_date": 1476206652,
    "last_error_message": "Connection timed out"
  }
}

in which the attribute "has_custom_certificate" : false means it did't get my certificate :\

What am i doing wrong here ?

Any alternatives to PostMan ??

One Step Further

I tried the HttpClient as below but it didn't work eighter :\

public string SetWebHook()
    {
        FileStream paramFileStream = new FileStream(@"E:\PATH.......\YOURPUBLIC.pem", FileMode.Open);
        HttpContent fileStreamContent = new StreamContent(paramFileStream);
        var response = string.Empty;
        using (var client = new HttpClient())
        using (var formData = new MultipartFormDataContent())
        {
            formData.Add(fileStreamContent, "Certificate", "YOURPUBLIC.pem");
             response = client.PostAsync("https://api.telegram.org/botMYTOKEN/setWebhook?url=MYSERVERIP:443/api/webhook", formData).Result.ToString();
        }
        return response;
    }

Upvotes: 1

Views: 1995

Answers (1)

Bahram Boroumandan
Bahram Boroumandan

Reputation: 40



You must use curl to upload your certificate (pem)
And
You should use HTTPS:// for your url

Upvotes: 0

Related Questions