Solved! Go to Solution.
public class TrustAllCertificatePolicy : System.Net.ICertificatePolicy { public TrustAllCertificatePolicy() { } public bool CheckValidationResult(ServicePoint sp, System.Security.Cryptography.X509Certificates.X509Certificate cert, WebRequest req, int problem) { return true; } }
System.Net.ServicePointManager.CertificatePolicy = new TrustAllCertificatePolicy();
public class QueryTrustCertificatePolicy : System.Net.ICertificatePolicy { private const uint CERT_E_UNTRUSTEDROOT = 0x800B0109; public QueryTrustCertificatePolicy() { } public bool CheckValidationResult(ServicePoint sp, System.Security.Cryptography.X509Certificates.X509Certificate cert, WebRequest req, int problem) { bool returnValue = problem == 0; if ((uint)problem == CERT_E_UNTRUSTEDROOT) { if (System.Windows.Forms.MessageBox.Show("The security cetificate is not from a trusted certification authority (" + cert.GetIssuerName() + "). Do you want to proceed?", "Security Alert", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Question, System.Windows.Forms.MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.Yes) returnValue = true; } return returnValue; } }
System.Net.ServicePointManager.CertificatePolicy = new QueryTrustCertificatePolicy();
ESRI.ArcGIS.Mobile.CatalogServices.TokenCredential tc = new ESRI.ArcGIS.Mobile.CatalogServices.TokenCredential("user", "password"); ESRI.ArcGIS.Mobile.CatalogServices.CatalogService cs = new ESRI.ArcGIS.Mobile.CatalogServices.CatalogService(); cs.Url = ESRI.ArcGIS.Mobile.CatalogServices.CatalogService.GetCatalogServiceUrlFromServiceUrl(_mobileServiceConnection1.Url); bool requiresToken = cs.RequiresTokens(); if (requiresToken) { string tokenService = cs.GetTokenServiceURL(); tokenService += ""; //** just to see it in the debugger. This was wrong in my case _mobileServiceConnection1.Url = ESRI.ArcGIS.Mobile.CatalogServices.TokenGenerator.GenerateAndApplyToken(_mobileServiceConnection1.Url, tc); }
ESRI.ArcGIS.Mobile.CatalogServices.TokenCredential tc = new ESRI.ArcGIS.Mobile.CatalogServices.TokenCredential("user", "password"); string token = ESRI.ArcGIS.Mobile.CatalogServices.TokenGenerator.GenerateToken("https://xxx.xxx.xxx.xxx/ArcGIS/tokens/", tc); _mobileServiceConnection1.Url += "?token=" + token;
public class TrustAllCertificatePolicy : System.Net.ICertificatePolicy { public TrustAllCertificatePolicy() { } public bool CheckValidationResult(ServicePoint sp, System.Security.Cryptography.X509Certificates.X509Certificate cert, WebRequest req, int problem) { return true; } }
System.Net.ServicePointManager.CertificatePolicy = new TrustAllCertificatePolicy();
public class QueryTrustCertificatePolicy : System.Net.ICertificatePolicy { private const uint CERT_E_UNTRUSTEDROOT = 0x800B0109; public QueryTrustCertificatePolicy() { } public bool CheckValidationResult(ServicePoint sp, System.Security.Cryptography.X509Certificates.X509Certificate cert, WebRequest req, int problem) { bool returnValue = problem == 0; if ((uint)problem == CERT_E_UNTRUSTEDROOT) { if (System.Windows.Forms.MessageBox.Show("The security cetificate is not from a trusted certification authority (" + cert.GetIssuerName() + "). Do you want to proceed?", "Security Alert", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Question, System.Windows.Forms.MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.Yes) returnValue = true; } return returnValue; } }
System.Net.ServicePointManager.CertificatePolicy = new QueryTrustCertificatePolicy();
Hello
I am new to using Mobile applications. I'm trying to sync between ArcGIS for Windows Mobile 10.0 and ArcGIS Server 10.0 and I assume its failing because of the security on my web services (IIS).
How do I use the code you have to accept any untrusted certificate? Is this the answer to the iussue I am also having?
Thanks so much!
Carma