В моем приложении я использую приведенный ниже код для проверки сертификата клиента
public static async Task<string> CallApi(string url, Context context)
{
var hostName = "mytestapp.azurewebsites.net";
var port = 443;
Stream keyin = Application.Context.Assets.Open("Server.pfx");
var password = "pass123";
using (MemoryStream memStream = new MemoryStream())
{
keyin.CopyTo(memStream);
var certificates = new X509Certificate2Collection(new X509Certificate2(memStream.ToArray(), password));
await Task.Run(() =>
{
// Create a TCP/IP client socket.
// machineName is the host running the server application.
TcpClient client = new TcpClient(hostName, port);
Console.WriteLine("Client connected.");
// Create an SSL stream that will close the client's stream.
SslStream sslStream = new SslStream(
client.GetStream(),
false,
ValidateServerCertificate);
// The server name must match the name on the server certificate.
try
{
sslStream.AuthenticateAsClient(hostName, certificates, SslProtocols.Tls12, true);
}
catch (AuthenticationException e)
{
Console.WriteLine("Exception: {0}", e.Message);
if (e.InnerException != null)
{
Console.WriteLine("Inner exception: {0}", e.InnerException.Message);
}
Console.WriteLine("Authentication failed - closing the connection.");
client.Close();
return;
}
});
}
return string.Empty;
}
после успешной аутентификации, я хотел бы сделать и запрос HTTP получить.
sslStream.AuthenticateAsClient(hostName, certificates, SslProtocols.Tls12, true);
Послеэто утверждение.Скажем, например, мне нужно позвонить ниже http Получить вызов
https://mytestapp.azurewebsites.net/api/GetUserProfile?userId="Sooraj"
Как я могу вызвать этот вызов?Или можно реализовать тоже самое?
Пожалуйста, помогите