Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8992065
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:52:10+00:00 2026-06-15T22:52:10+00:00

I would like to implement AWS like HMAC-SHA Signature algorithm for REST API service

  • 0

I would like to implement AWS like HMAC-SHA Signature algorithm for REST API service on Asp.Net MVC 3. Are there any best practices to generate user’s public key and secret?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T22:52:12+00:00Added an answer on June 15, 2026 at 10:52 pm

    We’ve built a similar system. The question that @James references gives very good information. Be sure to read it. If possible, only deploy your service over SSL/TLS.

    With HMAC-SHA signature you don’t need a public key. There is one secret key shared by the server (service) and the client that is used to compute the signature. Per the question on the security site referenced above, make sure you have different keys for each client.

    For each client you should also have service client id of some sort that is different than any other Ids you have to identify the client. This service client id is sent in the request header so you can identify the client. Once you’ve identified the client, you can obtain the required information about the client including the client’s service key.

    In addition to the service client id, the request header should contain the actual signature that was generated. I would also recommend including a time stamp in the header as well (more on this below). So your request would have headers similar to these:

    MySvc-Clientid: ServiceId
    MySvc-Signature: Signature
    MySvc-Timestamp: TimeStamp
    

    To generate client keys using .NET/C# you can create a method that generates a string representation of a Rijndael key which can be delivered to the client. Here is an example.

        public string CreateServiceClientKey()
        {
            SymmetricAlgorithm symAlg = SymmetricAlgorithm.Create("Rijndael");
    
            symAlg.KeySize = 128;
    
            byte[] key = symAlg.Key;
    
            StringBuilder sb = new StringBuilder(key.Length * 2);
    
            foreach (byte b in key)
            {
                sb.AppendFormat("{0:x2}", b);
            }
    
            return sb.ToString();
        }
    

    In our system, when a new service client is enabled, a service client id and service key are generated and stored in the database for the client. The service client id could just be a GUID.

    The client’s service key is a shared secret between you and the client. Only deliver it to the client via a secure mechanism, such as a authenticated portion of your website running on SSL/TLS. Otherwise, you open yourself up to someone else obtaining the secret key.

    The timestamp should be generated by the client and be included in the string to sign from which the signature is generated. This adds time specific variability to the signature. AWS does this as well.

    In regard to the string to sign, on your side I’d also recommend defining an interface that you program to for building your string to sign when comparing against the request signature. This will allow you to build to different implementations for different services or even different operations. This came in handy for our implementation. Here is an example:

    public interface IStringToSignBuilder
    {
        string Build(ServiceSignatureDetails details);
    }
    
    /// <summary>
    /// Class is a data entity that defines the specific details
    /// required for a Service Signature
    /// </summary>
    public class ServiceSignatureDetails
    {
        public string HttpMethod { get; set; }
        public string ServiceClientId { get; set; }
        public string ServiceClientKey { get; set; }
        public string UriAbsolutePath { get; set; }
        public string DomainName { get; set; }
        public string CompanyName { get; set; }
        public string DateTimeStamp { get; set; }
        public string Data { get; set; }
    }
    

    You can then build specific implementations of IStringToSignBuilder that meet your needs and inject the correct one into your code accordingly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to implement an API for my web based service. I've been
I would like to implement a high-traffic restful .NET 4.0 WCF service which can
I would like to implement exception handling on a ASP.NET application. How do you
I would like to implement a simple queueing service specific to a project. Where
I would like to implement a switch button, android.widget.Switch (available from API v.14). <Switch
I would like to implement user authentication using OpenID. Is there anything unique in
I would like to implement an algorithm which will find the bounding rectangles of
I would like to implement an interactive evolutionary algorithm for generating music (probably just
I would like to implement a distinct thread for each route in apache camel.I
I would like to implement a very simple way to store a variable containing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.