मेरे पास एक विंडोज फोन ऐप है, जो 8.1 के लिए बनाया गया है, और कार्यों में से एक क्लाइंट-सर्वर प्रमाणपत्र परिदृश्य था। मेरा ऐप ठीक काम करता है, मैं क्लाइंट प्रमाणपत्र भेज सकता हूं और सर्वर पर लॉगिन कर सकता हूं। हालांकि विंडोज 8.10.14xxxx में अपग्रेड करने के बाद यह संभव नहीं था। मैंने वायरशर्क निशान लिया और ऐसा लगता है कि प्रमाण पत्र कभी नहीं भेजा जाता है। संदेश की सामग्री लंबाई 0.नवीनतम विंडोज फोन को अपग्रेड करने के बाद प्रमाण पत्र भेजने में विफल 8.1
मैं प्रमाण पत्र दर्ज करने के लिए HttpClient.SendAsync
(प्रतीक्षा) और HttpBaseProtocolFilter
का उपयोग करता हूं। यह अपग्रेड से पहले सही काम किया।
कोई विचार? क्या कुछ टूट गया है?
सबसे पहले मैं pfx स्थापित करने हूँ
async private void btnInstall_Click(object sender, RoutedEventArgs e)
{
//Install the self signed client cert to the user certificate store
string CACertificate = null;
try
{
Uri uri = new Uri("ms-appx:///certificates/test.pfx");
var file = await Windows.Storage.StorageFile.GetFileFromApplicationUriAsync(uri);
IBuffer buffer = await FileIO.ReadBufferAsync(file);
using (DataReader dataReader = DataReader.FromBuffer(buffer))
{
byte[] bytes = new byte[buffer.Length];
dataReader.ReadBytes(bytes);
// convert to Base64 for using with ImportPfx
CACertificate = System.Convert.ToBase64String(bytes);
}
await CertificateEnrollmentManager.UserCertificateEnrollmentManager.ImportPfxDataAsync(
CACertificate,
"xxxxx",
ExportOption.Exportable,
KeyProtectionLevel.NoConsent,
InstallOptions.None,
"ClientCert1");
}
catch (Exception ex)
{
//;
}
}
तब मैं सेवा
string serviceURL = "https://my.web.services";
Certificate cert = null;
CertificateQuery query = new CertificateQuery();
query.FriendlyName = "ClientCert1";
IReadOnlyCollection<Certificate> certs = await CertificateStores.FindAllAsync(query);
HttpBaseProtocolFilter bpf = new HttpBaseProtocolFilter();
//if you install the CA you don't need to ignore the ServerCertificate Errors
//bpf.IgnorableServerCertificateErrors.Add(ChainValidationResult.Untrusted);
if (certs.Count > 0)
{
cert = certs.ElementAt(0);
bpf.ClientCertificate = cert;
}
HttpClient httpClient = new HttpClient(bpf);
try
{
var response = await httpClient.GetInputStreamAsync(new Uri(serviceURL));
//take data
}
catch (Exception ex)
{
//0x80072F0D
}
मैं हमेशा एक को छोड़कर (0x80072F0D
) ले रहा हूँ बोल रहा हूँ जब 8.10.14xxxx
विंडोज फोन में चल रहा है। मेरा कोड अपडेट से पहले काम करता था, अब मैं हमेशा यह रिटर्न कोड ले रहा हूं। प्रमाणपत्र httpClient में लोड किया गया है। जब मैं डीबगर के साथ ऐप को रोकता हूं तो ऐसा लगता है कि प्रमाणपत्र वहां है, हालांकि 0x800072F0D
का अर्थ है कि प्रमाणपत्र भेजा नहीं गया है ???
परिदृश्य में एक मध्यवर्ती प्रमाणपत्र प्राधिकरण है। वह प्रमाणपत्र पीएफएक्स में शामिल है। क्या मुझे इसे किसी भी तरह स्थापित करने की ज़रूरत है?
क्या आपके पास एक रिप्रो है? – kiewic
@kiewic क्या आप इस मुद्दे को जानते हैं? मैं कुछ स्रोत कोड साझा कर सकता हूं। – cateof
हां, मैं एक नज़र डाल सकता हूं। आप गिटहब या कहीं और पर रेपो डाल सकते हैं। – kiewic