Related: Make Https call using HttpClient
Here's an example that illustrates how I'm doing Web Service calls:
class Program
{
static void Main(string[] args)
{
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
var client = new HttpClient();
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(@"text/javascript") { CharSet = "utf-8" });
client.BaseAddress = new Uri("https://...");
HttpResponseMessage msg = client.GetAsync("jobs").Result;
string json = msg.Content.ReadAsStringAsync().Result;
// Deserialize this for later use
}
}
As I understand it from the answers there, as well as from this, this will establish a secure TLS connection and messages will be encrypted.
My understanding from the Wikipedia description of TLS 1.2 as well as the previously-mentioned documents and Q&A is that it uses public-key cryptography to authenticate the identity of the server and AES to do the exchange. However, Wikipedia's vague as to the exact details (e.g. the AES key size and mode, how the key is exchanged and stored, etc.). How is this handled in HttpClient
? What AES key size and mode is it using (if it is, in fact, using AES), how does it do the key exchange, and how does it store the key?