久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

<tfoot id='tjks5'></tfoot>

    1. <i id='tjks5'><tr id='tjks5'><dt id='tjks5'><q id='tjks5'><span id='tjks5'><b id='tjks5'><form id='tjks5'><ins id='tjks5'></ins><ul id='tjks5'></ul><sub id='tjks5'></sub></form><legend id='tjks5'></legend><bdo id='tjks5'><pre id='tjks5'><center id='tjks5'></center></pre></bdo></b><th id='tjks5'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='tjks5'><tfoot id='tjks5'></tfoot><dl id='tjks5'><fieldset id='tjks5'></fieldset></dl></div>

      <legend id='tjks5'><style id='tjks5'><dir id='tjks5'><q id='tjks5'></q></dir></style></legend>

    2. <small id='tjks5'></small><noframes id='tjks5'>

        <bdo id='tjks5'></bdo><ul id='tjks5'></ul>

      如何從 PKCS#12 字節(jié)數(shù)組構(gòu)造 X509Certificate2 拋出

      How can constructing an X509Certificate2 from a PKCS#12 byte array throw CryptographicException(quot;The system cannot find the file specified.quot;)?(如何從 PKCS#12 字節(jié)數(shù)組構(gòu)造 X509Certificate2 拋出 CryptographicException(“系統(tǒng)

        • <bdo id='zS1We'></bdo><ul id='zS1We'></ul>

          <small id='zS1We'></small><noframes id='zS1We'>

            <tbody id='zS1We'></tbody>

          <i id='zS1We'><tr id='zS1We'><dt id='zS1We'><q id='zS1We'><span id='zS1We'><b id='zS1We'><form id='zS1We'><ins id='zS1We'></ins><ul id='zS1We'></ul><sub id='zS1We'></sub></form><legend id='zS1We'></legend><bdo id='zS1We'><pre id='zS1We'><center id='zS1We'></center></pre></bdo></b><th id='zS1We'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='zS1We'><tfoot id='zS1We'></tfoot><dl id='zS1We'><fieldset id='zS1We'></fieldset></dl></div>
            <legend id='zS1We'><style id='zS1We'><dir id='zS1We'><q id='zS1We'></q></dir></style></legend>
            <tfoot id='zS1We'></tfoot>
                本文介紹了如何從 PKCS#12 字節(jié)數(shù)組構(gòu)造 X509Certificate2 拋出 CryptographicException(“系統(tǒng)找不到指定的文件.")?的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

                問題描述

                限時(shí)送ChatGPT賬號(hào)..

                我正在嘗試從字節(jié)數(shù)組中的 PKCS#12 blob 構(gòu)造 X509Certificate2 并得到一個(gè)相當(dāng)令人費(fèi)解的錯(cuò)誤.此代碼在 Windows XP 上具有管理員權(quán)限的桌面應(yīng)用程序中運(yùn)行.

                I'm trying to construct an X509Certificate2 from a PKCS#12 blob in a byte array and getting a rather puzzling error. This code is running in a desktop application with administrator rights on Windows XP.

                堆棧跟蹤如下,但我在嘗試排除故障時(shí)迷路了,因?yàn)?_LoadCertFromBlob 被標(biāo)記為 [MethodImpl(MethodImplOptions.InternalCall)].

                The stack trace is as follows, but I got lost trying to troubleshoot because _LoadCertFromBlob is marked [MethodImpl(MethodImplOptions.InternalCall)].

                System.Security.Cryptography.CryptographicException: The system cannot find the file specified.
                  at System.Security.Cryptography.CryptographicException.ThrowCryptogaphicException(Int32 hr)
                  at System.Security.Cryptography.X509Certificates.X509Utils._LoadCertFromBlob(Byte[] rawData, IntPtr password, UInt32 dwFlags, Boolean persistKeySet, SafeCertContextHandle& pCertCtx)
                  at System.Security.Cryptography.X509Certificates.X509Certificate.LoadCertificateFromBlob(Byte[] rawData, Object password, X509KeyStorageFlags keyStorageFlags)
                  at System.Security.Cryptography.X509Certificates.X509Certificate2..ctor(Byte[] rawData, String password, X509KeyStorageFlags keyStorageFlags)
                

                Blob 是由 BouncyCastle for C#<生成的真正 PKCS#12/a> 包含 RSA 私鑰和證書(自簽名或最近向 CA 注冊(cè))——我正在嘗試將私鑰和證書從 BouncyCastle 庫(kù)轉(zhuǎn)換為 System.Security.Cryptography 庫(kù)通過從一個(gè)導(dǎo)出并導(dǎo)入到另一個(gè).該代碼適用于它嘗試過的絕大多數(shù)系統(tǒng).我只是從未見過該構(gòu)造函數(shù)拋出的特定錯(cuò)誤.那個(gè)盒子上可能有某種環(huán)境怪異.

                The blob is a true PKCS#12 generated by BouncyCastle for C# containing a RSA private key and certificate (either self-signed or recently enrolled with a CA) -- what I'm trying to do is convert the private key and certificate from the BouncyCastle library to the System.Security.Cryptography library by exporting from one and importing to the other. This code works on the vast majority of systems it's been tried on; I've just never seen that particular error thrown from that constructor. It may be some sort of environmental weirdness on that one box.

                編輯 2: 錯(cuò)誤發(fā)生在不同城市的不同環(huán)境中,我無(wú)法在本地重現(xiàn)它,因此我最終可能不得不將其歸咎于 XP 損壞安裝.

                EDIT 2: The error is occurring in a different environment in a different city, and I'm unable to reproduce it locally, so I may end up having to chalk it up to a broken XP installation.

                既然你問了,這里是有問題的片段.該代碼采用 BouncyCastle 表示形式的私鑰和證書,從個(gè)人密鑰存儲(chǔ)中刪除相同專有名稱的任何先前證書,并通過中間 PKCS#12 blob 將新的私鑰和證書導(dǎo)入個(gè)人密鑰存儲(chǔ).

                Since you asked, though, here is the fragment in question. The code takes a private key and certificate in BouncyCastle representation, deletes any previous certificates for the same Distinguished Name from the personal key store, and imports the new private key and certificate into the personal key store via an intermediate PKCS#12 blob.

                // open the personal keystore
                var msMyStore = new X509Store(StoreName.My);
                msMyStore.Open(OpenFlags.MaxAllowed);
                
                // remove any certs previously issued for the same DN
                var oldCerts =
                    msMyStore.Certificates.Cast<X509Certificate2>()
                        .Where(c => X509Name
                                        .GetInstance(Asn1Object.FromByteArray(c.SubjectName.RawData))
                                        .Equivalent(CurrentCertificate.SubjectDN))
                        .ToArray();
                if (oldCerts.Length > 0) msMyStore.RemoveRange(new X509Certificate2Collection(oldCerts));
                
                // build a PKCS#12 blob from the private key and certificate
                var pkcs12store = new Pkcs12StoreBuilder().Build();
                pkcs12store.SetKeyEntry(_Pkcs12KeyName,
                                        new AsymmetricKeyEntry(KeyPair.Private),
                                        new[] {new X509CertificateEntry(CurrentCertificate)});
                var pkcs12data = new MemoryStream();
                pkcs12store.Save(pkcs12data, _Pkcs12Password.ToCharArray(), Random);
                
                // and import it.  this constructor call blows up
                _MyCertificate2 = new X509Certificate2(pkcs12data.ToArray(),
                                                       _Pkcs12Password,
                                                       X509KeyStorageFlags.Exportable);
                msMyStore.Add(_MyCertificate2);
                msMyStore.Close();
                

                推薦答案

                你有 PKCS#12 還是只有 PFX 文件?在 Microsoft 世界中是一樣的,但其他人認(rèn)為不同(參見 此存檔頁(yè)面).

                Do you have PKCS#12 or just PFX-file? In the Microsoft world it is the same, but other think another (see this archived page).

                你可以試試關(guān)注

                X509Certificate2 cert = X509Certificate2(byte[] rawData, "password");
                X509Certificate2 cert2 = X509Certificate2(byte[] rawData, "password",
                              X509KeyStorageFlags.MachineKeySet |
                              X509KeyStorageFlags.PersistKeySet |
                              X509KeyStorageFlags.Exportable);
                

                (X509Certificate2(Byte[])) 或

                X509Certificate2 cert = X509Certificate2("C:Pathmy.pfx", "password");
                

                (請(qǐng)參閱 X509Certificate2(String, String) 和 Import(String, String, X509KeyStorageFlags) 如果您需要使用一些標(biāo)志,請(qǐng)參閱 Microsoft Docs)

                (see X509Certificate2(String, String) and Import(String, String, X509KeyStorageFlags) on Microsoft Docs if you need use some flags)

                已更新:如果您插入代碼片段而不僅僅是異常堆棧跟蹤,將會(huì)很有幫助.

                UPDATED: It would be helpful if you insert a code fragment and not only the exception stack trace.

                您使用哪個(gè) X509KeyStorageFlags?您可以使用 Process Monitor 找出哪個(gè)文件找不到X509Certificate2 構(gòu)造函數(shù).例如,在出現(xiàn)問題的 Windows XP 上,當(dāng)前用戶沒有默認(rèn)密鑰容器.您可以創(chuàng)建它并重試導(dǎo)入.

                Which X509KeyStorageFlags do you use? You can use Process Monitor to find out which file could not find the X509Certificate2 constructor. It can be for example that there are no default key container for the current user on the Windows XP having the problem. You can create it and retry the import.

                這篇關(guān)于如何從 PKCS#12 字節(jié)數(shù)組構(gòu)造 X509Certificate2 拋出 CryptographicException(“系統(tǒng)找不到指定的文件.")?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

                相關(guān)文檔推薦

                What are good algorithms for vehicle license plate detection?(車牌檢測(cè)有哪些好的算法?)
                onClick event for Image in Unity(Unity中圖像的onClick事件)
                Running Total C#(運(yùn)行總 C#)
                Deleting a directory when clicked on a hyperlink with JAvascript.ASP.NET C#(單擊帶有 JAvascript.ASP.NET C# 的超鏈接時(shí)刪除目錄)
                asp.net listview highlight row on click(asp.net listview 在單擊時(shí)突出顯示行)
                Calling A Button OnClick from a function(從函數(shù)調(diào)用按鈕 OnClick)
                <legend id='KBBAY'><style id='KBBAY'><dir id='KBBAY'><q id='KBBAY'></q></dir></style></legend>
                <i id='KBBAY'><tr id='KBBAY'><dt id='KBBAY'><q id='KBBAY'><span id='KBBAY'><b id='KBBAY'><form id='KBBAY'><ins id='KBBAY'></ins><ul id='KBBAY'></ul><sub id='KBBAY'></sub></form><legend id='KBBAY'></legend><bdo id='KBBAY'><pre id='KBBAY'><center id='KBBAY'></center></pre></bdo></b><th id='KBBAY'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='KBBAY'><tfoot id='KBBAY'></tfoot><dl id='KBBAY'><fieldset id='KBBAY'></fieldset></dl></div>

              1. <small id='KBBAY'></small><noframes id='KBBAY'>

                <tfoot id='KBBAY'></tfoot>

                      <tbody id='KBBAY'></tbody>
                        <bdo id='KBBAY'></bdo><ul id='KBBAY'></ul>

                        1. 主站蜘蛛池模板: 亚洲交性 | 一区二区三区视频 | 亚洲欧洲精品在线 | 九色 在线| 中文字幕视频三区 | 国产福利资源在线 | 中文字幕免费视频 | 一级片免费网站 | 91久久精品一区二区二区 | 国产91久久久久蜜臀青青天草二 | 成人1区2区 | 在线免费观看视频你懂的 | 欧美性一级 | 婷婷在线免费 | 欧美一区二区小视频 | 精品国产伦一区二区三区观看体验 | 激情av免费看 | 奇米四色影视 | 美国一级片在线观看 | 国产偷录视频叫床高潮对白 | 国产黄色电影 | 毛片av免费看 | 成年人免费网站 | 成人在线电影在线观看 | 日韩精品在线观看一区二区 | 久久久国产精品 | 欧美不卡一区二区三区 | 97精品视频在线观看 | 国产精品毛片久久久久久久 | 91精品国产99| 欧美福利久久 | 中文字幕av一区二区三区 | 成人在线网址 | 黄色成人在线 | 亚洲免费在线 | av网站免费观看 | 97伦理| 一区二区三区小视频 | 亚洲国产成人精品女人久久久野战 | 色天天综合 | a在线观看 |