0
Q1: 以下のWebサービスがreq.getResponse()から返されることがなく、タイムアウトエラーが発生する理由は何か考えられます。httpwebrequest.getResponse Webサービスのタイムアウト
webserviceは、ユーザーに代わってhttpwebrequestオブジェクトを作成し、コールバックスレッドが証明書を提供するのを待ってから結果を返します。
私がここで紛失しているかもしれないことは何ですか?(テストサーバーなどで何らかの過失があるかもしれません)。 (私は問題なしでhttpwebrequest +コールバックを外部Webサービスの前に使用したことに注意してください)
Q2:httpsserverからの証明書をコールバックで取得するのに同期的な方法はありますか?
[WebService(Namespace = "http://testserver")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class main : System.Web.Services.WebService
{
static main pointer;
private static bool ValidateRemoteCertificate(
object sender,
X509Certificate certificate,
X509Chain chain,
SslPolicyErrors policyErrors
)
{
X509Certificate2 cert = new X509Certificate2(certificate);
HttpWebRequest wbr= (HttpWebRequest)sender;
pointer.Application[wbr.RequestUri.ToString()] = cert.Thumbprint;
return true;
}
public main()
{
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(ValidateRemoteCertificate);
pointer = this;
}
[WebMethod]
public string verifyCertificate(string thumb, string sslsite)
{
string result = "";
try
{
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(sslsite);
pointer.Application[req.RequestUri.ToString()] = null;
req.GetResponse();
/* while (Application[req.RequestUri.ToString()] == null)
{
Thread.CurrentThread.Join(1000);
}
*/
result = (string)Application[req.RequestUri.ToString()];
}
catch (Exception e)
{
result = e.ToString();
}
return result;
}
}
あなた自身の答え、FYIを受け入れることができます。 –