Search code examples
c#encryptionkeyprivatepublic

Exchanging Public Keys in .NET


I am trying to exchange the public keys of a client and a server.

As soon as I make the request from the client and send the key to the server, the following exception is being raised by the server:

enter image description here

The exception is an HttpRequestValidationException. It says that a potentially dangerous Request.Form value was detected from the client (contents of public key).

What does this exception mean? Why am I not allowed to exchange public keys using normal POST requests?

I tried embedding the public key into a JObject, yet the same exception is raised. How can I solve this?


Solution

  • I found the answer.

    I had to introduce this line into my web.config file on the server:

    <httpRuntime requestValidationMode="2.0" />