我已經下載了通過https提供API的產品的試用版。目前我的asp.net mvc的web應用程序中我做了以下執行的API調用該產品的試用版: -Security.Authentication.AuthenticationException:根據驗證程序,遠程證書無效
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Create(RackJoin rj, FormCollection formValues)
{
string controllername = RouteData.Values["controller"].ToString();
if (ModelState.IsValid)
{
var message = "";
var status = "";
long assetid = new long();
XmlDocument doc = new XmlDocument();
using (var client = new WebClient())
{
var query = HttpUtility.ParseQueryString(string.Empty);
foreach (string key in formValues)
{
query[key] = this.Request.Form[key];
}
query["username"] = System.Web.Configuration.WebConfigurationManager.AppSettings["ApiUserName"];
query["password"] = System.Web.Configuration.WebConfigurationManager.AppSettings["ApiPassword"];
string apiurl = "https://win-spdev:8400/servlets/AssetServlet";
//code goes here…..
var url = new UriBuilder(apiurl);
url.Query = query.ToString();
,但我會出現以下情況例外: -
發生錯誤:System.Security.Authentication.AuthenticationException: 根據驗證 過程,遠程證書無效。在 System.Net.Security.SslState.StartSendAuthResetSignal在 System.Net.Security.SslState(ProtocolToken 消息,AsyncProtocolRequest asyncRequest,例外的例外)在 System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken 消息,AsyncProtocolRequest asyncRequest) .StartSendBlob(字節[]來電,的Int32 計數,AsyncProtocolRequest asyncRequest)在 System.Net.Security.SslState.ProcessReceivedBlob(字節[]緩衝液,的Int32 計數,AsyncProtocolRequest asyncRequest)在 System.Net.Security.SslState.StartReadFrame (Byte [] buffer,Int32 readBytes,AsyncProtocolRequest asyncRequest)at System.Net.Security.SslState.StartReceiveBlob(字節[]緩衝液, AsyncProtocolRequest asyncRequest)在 System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken 消息,AsyncProtocolRequest asyncRequest)在 System.Net.Security.SslState.StartSendBlob(字節[]來電,的Int32 計數,AsyncProtocolRequest asyncRequest)處 System.Net.Security.SslState.StartReadFrame(字節[]緩衝 System.Net.Security.SslState.ProcessReceivedBlob(字節[]緩衝液,的Int32 計數,AsyncProtocolRequest asyncRequest)的Int32 的ReadBytes,AsyncProtocolRequest asyncRequest)在 System.Net.Security.SslState.StartReceiveBlob(Byte [] buffer, AsyncProtocolRequest asyncRequest)at S ystem.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken 消息,AsyncProtocolRequest asyncRequest)在 System.Net.Security.SslState.StartSendBlob(字節[]來電,的Int32 計數,AsyncProtocolRequest asyncRequest)在 System.Net.Security.SslState .ProcessReceivedBlob(字節[]緩衝液,的Int32 計數,AsyncProtocolRequest asyncRequest)在 System.Net.Security.SslState.StartReadFrame(字節[]緩衝液,的Int32 的ReadBytes,AsyncProtocolRequest asyncRequest)在 System.Net.Security.SslState.StartReceiveBlob (Byte [] buffer, AsyncProtocolRequest asyncRequest)at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message,As yncProtocolRequest asyncRequest)在 System.Net.Security.SslState.StartSendBlob(字節[]來電,的Int32 計數,AsyncProtocolRequest asyncRequest)在 System.Net.Security.SslState.ForceAuthentication(布爾receiveFirst, 字節[]緩衝液,AsyncProtocolRequest asyncRequest )在在 System.Threading.ExecutionContext.RunInternal(ExecutionContext中 的ExecutionContext在System.Net.TlsStream.CallProcessAuthentication System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult)(對象 狀態),ContextCallback回調,對象的狀態,布爾型 preserveSyncCtx) 系統。Threading.ExecutionContext.Run(的ExecutionContext 的ExecutionContext,ContextCallback回調,對象的狀態,布爾 preserveSyncCtx)在 System.Threading.ExecutionContext.Run(的ExecutionContext 的ExecutionContext,ContextCallback回調,對象狀態)在 System.Net.TlsStream.ProcessAuthentication( LazyAsyncResult結果) System.Net.TlsStream.Write(Byte [] buffer,Int32 offset,Int32 size)at System.Net.PooledStream.Write(Byte [] buffer,Int32 offset,Int32 size) at System.Net .ConnectStream.WriteHeaders(布爾異步)
巴林在米IND,我可以調用API沒有任何問題,如果我直接從我的Web瀏覽器中調用的API如下: -
https://win-spdev:8400/servlets/AssetServlet?username=tmsservice&password=test2test2&assetType=Rack&operation=UpdateAsset&assetName=rack9090909858585&accountName=GROUP&siteName=test%20site&productName=rackproductone
那麼,這個問題涉及到的是,API是通過https,而且因爲我在我的開發機器內部使用產品的試用版時,是否應該安裝有效的證書?或者問題與安全認證無關? 謝謝
非常感謝它運作良好,並確保生產我將使用有效的證書。 –
我得到同樣的錯誤,而從控制檯應用程序連接smtp服務器,在主函數的開始使用代碼,它解決了問題....非常感謝你分享它。 –