1
我問這個問題,因爲當我使用Azure REST API時,它需要客戶端證書。 在C#中,我可以寫這樣的代碼:如何使用Javascript/JQuery使X509證書發出REST請求?
**X509Store certificateStore = new X509Store(StoreName.My, StoreLocation.CurrentUser);
certificateStore.Open(OpenFlags.ReadOnly);
X509Certificate2Collection certs = certificateStore.Certificates.Find(X509FindType.FindByThumbprint,
certThumbprint, false);**
if (certs.Count == 0)
{
Console.WriteLine("Couldn't find the certificate with thumbprint:" + certThumbprint);
return;
}
certificateStore.Close();
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(
new Uri("https://management.core.windows.net/" + subscriptionId + "/services/hostedservices"));
request.Method = "POST";
**request.ClientCertificates.Add(certs[0]);**
但是我應該如何給JS樣的要求?
一個選擇是讓你的js在你的服務器上打一個使用C#的請求的api。 –
只有這樣? – EthenHY
它適用於Windows 8應用程序或常規Web應用程序嗎? –