https를 통해서만 사용할 수있는 웹 서비스를 사용하는 데 어려움을 겪고 있습니다.HTTPS를 통한 Xamarin Android 웹 서비스
이 문제를 해결하는 데 많은 어려움을 겪고있는 여러 다른 사람들의 게시물을 읽었지 만, 지금까지 본 답변 중 아무 것도 나를 위해 문제를 해결하지 못했기 때문에 여기에서 내 문제를 설명하려고합니다. 여러분 중 일부는 이러한 장애물을 극복하는 방법을 알고 있습니다.
저는 Android 용으로 특별히 개발 된 Xamarin Studio 6.1.1을 사용하고 있습니다. 프로젝트의 "Android Build"에서 "HttpClient Implementation"을 "AndroidClientHandler"(최신 구현 인 것으로 보이며 TLS 1.2를 지원해야 함)로 설정했습니다.
웹 서비스에 웹 참조 (WCF가 아닌)를 추가하고 메시지가 표시되면 로그인 정보를 제공했습니다. 지금까지 모든 것이 예상대로 진행되었습니다.
참고 : Visual Studio의 콘솔 응용 프로그램에서 웹 서비스를 테스트했으며 예상대로 작동합니다.
그러나 웹 서비스의 메소드 중 하나를 호출하려고하면 다른 많은 사람들이이 "오류 : TrustFailure (인증 또는 암호 해독에 실패했습니다.)가 발생했습니다.) ".
이전 게시 된 솔루션 중 몇 가지를 시도했지만 아무 도움이되지 않습니다.
ServicePointManager.ServerCertificateValidationCallback += CertificateValidationCallBack;
1.B) 콜백 함수 : ServicePointManager위한 콜백 기능을 제공
1.A
)private static bool CertificateValidationCallBack(
object sender,
System.Security.Cryptography.X509Certificates.X509Certificate certificate,
System.Security.Cryptography.X509Certificates.X509Chain chain,
System.Net.Security.SslPolicyErrors sslPolicyErrors)
{
// If the certificate is a valid, signed certificate, return true.
if (sslPolicyErrors == System.Net.Security.SslPolicyErrors.None)
{
return true;
}
// If there are errors in the certificate chain, look at each error to determine the cause.
if ((sslPolicyErrors & System.Net.Security.SslPolicyErrors.RemoteCertificateChainErrors) != 0)
{
if (chain != null && chain.ChainStatus != null)
{
foreach (System.Security.Cryptography.X509Certificates.X509ChainStatus status in chain.ChainStatus)
{
if ((certificate.Subject == certificate.Issuer) &&
(status.Status == System.Security.Cryptography.X509Certificates.X509ChainStatusFlags.UntrustedRoot))
{
// Self-signed certificates with an untrusted root are valid.
continue;
}
else
{
if (status.Status != System.Security.Cryptography.X509Certificates.X509ChainStatusFlags.NoError)
{
// If there are any other errors in the certificate chain, the certificate is invalid,
// so the method returns false.
return false;
}
}
}
}
// When processing reaches this line, the only errors in the certificate chain are
// untrusted root errors for self-signed certificates. These certificates are valid
// for default Exchange server installations, so return true.
return true;
}
else
{
// In all other cases, return false.
return false;
}
}
2) AesCryptoServiceProvider 인스턴스 만들기
System.Security.Cryptography.AesCryptoServiceProvider b = new System.Security.Cryptography.AesCryptoServiceProvider();
을
누구나 솔루션을 가질 수 있다면 분명히 꽤 일반적인 문제입니다. 테이트는 ... 난 단지 너무 많은 머리가 알려
종류와 관련, Aidal
아하! 이것은 실제로 현재 버전의 버그입니다. 즉, 내가하는 일과 관계없이이 작업을 수행 할 수 없다는 것을 의미합니다. 이 경우 유일한 대안은 수정을 기다리는 것입니까? – Aidal
음, 어떤 포트 번호를 사용하고 있습니까? 443은 괜찮을거야. 또한 인증 확인 콜백에서 'true'를 반환하면 해결 방법으로도 도움이되지만 *는 모든 생산적인 앱 *의 옵션이 아닙니다. – Krumelur
포트가 443이 아니기 때문에 불행히도 변경을 요청할 수 없습니다. 이미 언급 한 해결 방법을 시도했지만 작동하지 않습니다. 문제의 서비스에서 몇 가지 응답을 직렬화했으며 문제가 곧 해결 될 것이라고 기대하면서 내 앱의 일부 응답을 처리하고 있습니다. 출시 페이지의 알려진 문제에 관심을 가져 주셔서 감사합니다. – Aidal