# Invalid Signature C#

**URL:** <https://devforum.zoom.us/t/invalid-signature-c/6542>\
**Category:** API and Webhooks\
**Created:** [November 6, 2019, 11:31pm UTC](https://devforum.zoom.us/t/invalid-signature-c/6542 "2019-11-06T23:31:48Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![pepkad](https://avatars.discourse-cdn.com/v4/letter/p/5f9b8f/32.png) [@pepkad](https://devforum.zoom.us/u/pepkad)\
**Post date:** [November 6, 2019, 11:31pm UTC](https://devforum.zoom.us/t/invalid-signature-c/6542/1 "2019-11-06T23:31:48Z")

</div>

**Description/Error**  
When generating a signature from a .net core 3.0 api server using the c# example from ([https://marketplace.zoom.us/docs/sdk/native-sdks/Web-Client-SDK/tutorial/generate-signature](https://marketplace.zoom.us/docs/sdk/native-sdks/Web-Client-SDK/tutorial/generate-signature)) it fails with an invalid signature error.

> {method: “join”, status: false, errorCode: 1, errorMessage: “Invalid signature.”, result: null}

C# Code:

> ![image](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/2X/c/c45ae003aa3bd39bc741cef798c268ff5d7b58a5.png)

Where as using ZoomMtg.generateSignature with the same data works.

> var signature = ZoomMtg.generateSignature({  
> meetingNumber: data.meetingNumber,  
> apiKey: data.apiKey,  
> apiSecret: data.apiSecret,  
> role: meetConfig.Role,  
> success: function(res){  
> console.log(res.result);  
> }  
> });

I’m really at a loss of where to go from here. Any advice would be appreciated .

Has anyone had any success generating signatures with the C# example? I do not have the ability or desire to deploy a nodejs server just for creating signatures.

Thanks  
-Daniel

---

<div class="post-metadata">

**Author:** ![tommy](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/tommy/32/72769_2.png) [@tommy](https://devforum.zoom.us/u/tommy)\
**Post date:** [November 7, 2019, 6:38am UTC](https://devforum.zoom.us/t/invalid-signature-c/6542/2 "2019-11-07T06:38:44Z")

</div>

Hey @pepkad,

Can you post your code here (in text) and steps to reproduce so that I can debug the issue on my end?

Thanks,  
Tommy

---

<div class="post-metadata">

**Author:** ![pepkad](https://avatars.discourse-cdn.com/v4/letter/p/5f9b8f/32.png) [@pepkad](https://devforum.zoom.us/u/pepkad)\
**Post date:** [November 7, 2019, 7:04pm UTC](https://devforum.zoom.us/t/invalid-signature-c/6542/3 "2019-11-07T19:04:10Z")

</div>

Hi Tommy,

Thanks for the reply, I’ve put my code into a github project. It is a .net core 3.0 server so you must have that installed first. ([https://dotnet.microsoft.com/download/dotnet-core/3.0](https://dotnet.microsoft.com/download/dotnet-core/3.0))

First clone the app:

git clone [https://github.com/DanielPepka/NetCoreZoomUs](https://github.com/DanielPepka/NetCoreZoomUs)

Then modify the zoom controller file to have an api key / secret as well as an email address that is associated with that account. (“TODO - SET THIS”)

> <https://github.com/DanielPepka/NetCoreZoomUs/blob/master/Controllers/ZoomController.cs>

From there you can either launch the app with visual studio or through the command line (dot net build / dotnet run)

 ![image](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/2X/1/1f2516b5b837ab3cdd39135e6b0f4792e078f51c.png)

---

<div class="post-metadata">

**Author:** ![pepkad](https://avatars.discourse-cdn.com/v4/letter/p/5f9b8f/32.png) [@pepkad](https://devforum.zoom.us/u/pepkad)\
**Post date:** [November 7, 2019, 7:06pm UTC](https://devforum.zoom.us/t/invalid-signature-c/6542/4 "2019-11-07T19:06:46Z")

</div>

What results is a webpage that had an iframe in it hosting a zoom player.

 ![image](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/2X/1/1d1850f7c6108f09c2679f22fe96b36c7926214e.png)

---

<div class="post-metadata">

**Author:** ![pepkad](https://avatars.discourse-cdn.com/v4/letter/p/5f9b8f/32.png) [@pepkad](https://devforum.zoom.us/u/pepkad)\
**Post date:** [November 7, 2019, 7:10pm UTC](https://devforum.zoom.us/t/invalid-signature-c/6542/5 "2019-11-07T19:10:23Z")

</div>

If you take the same code, and instead use the same api key / secret to generate the signagure using the ZoomMtg.generateSignature it works.

 ![image](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/2X/2/2eb299aa9bba6a0e1226f4e154bf491ca72f6111.png)

Modify this page ([https://github.com/DanielPepka/NetCoreZoomUs/blob/master/Views/Home/ZoomMeeting.cshtml](https://github.com/DanielPepka/NetCoreZoomUs/blob/master/Views/Home/ZoomMeeting.cshtml))

---

<div class="post-metadata">

**Author:** ![pepkad](https://avatars.discourse-cdn.com/v4/letter/p/5f9b8f/32.png) [@pepkad](https://devforum.zoom.us/u/pepkad)\
**Post date:** [November 7, 2019, 7:12pm UTC](https://devforum.zoom.us/t/invalid-signature-c/6542/6 "2019-11-07T19:12:07Z")

</div>

After modifying the ZoomMeeting.cshtml page you can rebuild / run and instead you get this page which works and connects to the meeting.

 ![image](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/2X/0/07bf348cc02bcec8d92abdc35dcd9befb1a6d151.png)

---

<div class="post-metadata">

**Author:** ![tommy](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/tommy/32/72769_2.png) [@tommy](https://devforum.zoom.us/u/tommy)\
**Post date:** [November 7, 2019, 8:43pm UTC](https://devforum.zoom.us/t/invalid-signature-c/6542/7 "2019-11-07T20:43:45Z")

</div>

Hey @pepkad,

Thank you for the detailed response!

May I ask the meetingNumber you are passing in?

Also can you try passing in meetingNumber and role as a Number type and not String type?

> <https://github.com/DanielPepka/NetCoreZoomUs/blob/master/Controllers/ZoomController.cs#L83>

> <https://github.com/DanielPepka/NetCoreZoomUs/blob/master/Controllers/ZoomController.cs#L85>

Thanks,  
Tommy

---

<div class="post-metadata">

**Author:** ![pepkad](https://avatars.discourse-cdn.com/v4/letter/p/5f9b8f/32.png) [@pepkad](https://devforum.zoom.us/u/pepkad)\
**Post date:** [November 7, 2019, 9:04pm UTC](https://devforum.zoom.us/t/invalid-signature-c/6542/8 "2019-11-07T21:04:06Z")

</div>

The meeting Id is generated by the endpoint, but you can also hardcode one by adding it to the meetingConfig. It then passes that id to the controller and skips the meeting creation step.

![image](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/2X/0/05a52e9835b575901470c7ab430d620bd7dba80d.png)

---

<div class="post-metadata">

**Author:** ![pepkad](https://avatars.discourse-cdn.com/v4/letter/p/5f9b8f/32.png) [@pepkad](https://devforum.zoom.us/u/pepkad)\
**Post date:** [November 7, 2019, 9:04pm UTC](https://devforum.zoom.us/t/invalid-signature-c/6542/9 "2019-11-07T21:04:43Z")

</div>

I also modified the role and meeting numbers to be ints instead of a string and it doesn’t change anything. Was a good thought though.

 ![image](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/2X/d/d9a991a8f939c38c99102368ad773d9f331b1ce2.png)

---

<div class="post-metadata">

**Author:** ![pepkad](https://avatars.discourse-cdn.com/v4/letter/p/5f9b8f/32.png) [@pepkad](https://devforum.zoom.us/u/pepkad)\
**Post date:** [November 7, 2019, 9:06pm UTC](https://devforum.zoom.us/t/invalid-signature-c/6542/10 "2019-11-07T21:06:05Z")

</div>

I could private message you the api key / secret if that would help.

---

<div class="post-metadata">

**Author:** ![tommy](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/tommy/32/72769_2.png) [@tommy](https://devforum.zoom.us/u/tommy)\
**Post date:** [November 7, 2019, 9:16pm UTC](https://devforum.zoom.us/t/invalid-signature-c/6542/11 "2019-11-07T21:16:09Z")

</div>

Hey @pepkad,

Can you push your changes to github so I can view and test?

Also are you trying to start or join the meeting?

(I don’t need API Key and Secret)

Thanks,  
Tommy

---

<div class="post-metadata">

**Author:** ![pepkad](https://avatars.discourse-cdn.com/v4/letter/p/5f9b8f/32.png) [@pepkad](https://devforum.zoom.us/u/pepkad)\
**Post date:** [November 7, 2019, 9:29pm UTC](https://devforum.zoom.us/t/invalid-signature-c/6542/12 "2019-11-07T21:29:47Z")

</div>

Done, I’ve modified the controller and zoommeeting.cshtml file. I added a hardcoded meeting number to a valid meeting on my account, and updated the controller to accept both the role and the meeting number as ints.

---

<div class="post-metadata">

**Author:** ![pepkad](https://avatars.discourse-cdn.com/v4/letter/p/5f9b8f/32.png) [@pepkad](https://devforum.zoom.us/u/pepkad)\
**Post date:** [November 7, 2019, 9:41pm UTC](https://devforum.zoom.us/t/invalid-signature-c/6542/13 "2019-11-07T21:41:20Z")

</div>

I’m trying to join a meeting that I’ve hosted which enables join before host.

![image](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/2X/f/f2838cb57436f5b0edb0b024383e35e96d677964.png)

---

<div class="post-metadata">

**Author:** ![tommy](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/tommy/32/72769_2.png) [@tommy](https://devforum.zoom.us/u/tommy)\
**Post date:** [November 7, 2019, 10:00pm UTC](https://devforum.zoom.us/t/invalid-signature-c/6542/14 "2019-11-07T22:00:07Z")

</div>

Hey @pepkad,

Can you send me the signature that is generated from your C# code? Feel free to private message it to me.

Also, can you try updating the Web SDK to the latest version, released a few hours ago 1.6.1.

> **[zoom/zoomus-jssdk](https://github.com/zoom/zoomus-jssdk)**
>
> zoom webclient jssdk Local NPM repository. Contribute to zoom/zoomus-jssdk development by creating an account on GitHub.

Thanks,  
Tommy

---

<div class="post-metadata">

**Author:** ![tommy](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/tommy/32/72769_2.png) [@tommy](https://devforum.zoom.us/u/tommy)\
**Post date:** [November 11, 2019, 5:42pm UTC](https://devforum.zoom.us/t/invalid-signature-c/6542/16 "2019-11-11T17:42:56Z")

</div>

Hey @pepkad,

Please try this code to generate the signature:

```cs
// this demo use vscode and .NET Core 2.2.5
// https://docs.microsoft.com/en-us/dotnet/core/tutorials/with-visual-studio-code
// https://dotnet.microsoft.com/download
// dotnet add package Microsoft.IdentityModel.Tokens
// dotnet add package System.IdentityModel.Tokens.Jwt
// https://www.red-gate.com/simple-talk/dotnet/net-development/jwt-authentication-microservices-net/
// https://www.jokecamp.com/blog/examples-of-creating-base64-hashes-using-hmac-sha256-in-different-languages/#csharp
// https://marketplace.zoom.us/docs/sdk/native-sdks/Web-Client-SDK/tutorial/generate-signature

using System;
using System.IdentityModel.Tokens.Jwt;
using System.Security.Claims;
using System.Security.Cryptography;
using System.Text;
using Microsoft.IdentityModel.Tokens;

namespace Zoom {
    class Program {
        static readonly char[] padding = { '=' };

        static void Main (string[] args) {
            Console.WriteLine ("Zoom copyright!");
            Console.WriteLine ("generate websdk token!");
            string apiKey = "apiKey";
            string apiSecret = "apiSecret";
            string meetingNumber = "";
            String ts = ToTimestamp(DateTime.UtcNow.ToUniversalTime ()).ToString();
            string role = "1";
            string token = GenerateToken (apiKey, apiSecret, meetingNumber, ts, role);
            Console.WriteLine (token);
        }

        public static long ToTimestamp (DateTime value) {
            long epoch = (value.Ticks - 621355968000000000) / 10000;
            return epoch;
        }

        public static string GenerateToken (string apiKey, string apiSecret, string meetingNumber, string ts, string role) {
            string message = String.Format ("{0}{1}{2}{3}", apiKey, meetingNumber, ts, role);
            apiSecret = apiSecret ?? "";
            var encoding = new System.Text.ASCIIEncoding ();
            byte[] keyByte = encoding.GetBytes (apiSecret);
            byte[] messageBytesTest = encoding.GetBytes (message);
            string msgHashPreHmac = System.Convert.ToBase64String (messageBytesTest);
            byte[] messageBytes = encoding.GetBytes (msgHashPreHmac);
            using (var hmacsha256 = new HMACSHA256 (keyByte)) {
                byte[] hashmessage = hmacsha256.ComputeHash (messageBytes);
                string msgHash = System.Convert.ToBase64String (hashmessage);
                string token = String.Format ("{0}.{1}.{2}.{3}.{4}", apiKey, meetingNumber, ts, role, msgHash);
                var tokenBytes = System.Text.Encoding.UTF8.GetBytes (token);
                return System.Convert.ToBase64String (tokenBytes).TrimEnd (padding);
            }
        }

    }
}

```

Thanks,  
Tommy
