高分 求助 c# 调用 truststore格式 证书

iamseason 2013-12-25 05:25:17
和工行做接口对接,给我发一个truststore后缀的证书,但是当我执行代码的时候报错“找不到申请的对象。”
是我的方法不对?

HttpWebRequest httpRequest.ClientCertificates.Add(new X509Certificate2("D:\OTS.truststore", "123"));

请问各位大侠,有对接过用过类似证书的指点迷津。谢谢。
...全文
348 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
提阿菲罗 2016-08-26
  • 打赏
  • 举报
回复
同样的问题 C# 如何调用truststore证书 急急急!
Eric沈 2013-12-31
  • 打赏
  • 举报
回复
我也是做工行的对接,出现这个问题
Eric沈 2013-12-31
  • 打赏
  • 举报
回复
我的证书的后缀与你的一样,我昨天又问工行的人,他们的证书是什么格式,他说是PFX格式,我在怀疑他是否给错证书了 ,这个 truststore后缀的证书是证书仓库,一般是放在tomcar里面,由tomcar读取的!
iamseason 2013-12-31
  • 打赏
  • 举报
回复
楼上,你是什么格式的证书,这个可以互转吗
iamseason 2013-12-31
  • 打赏
  • 举报
回复
我正在向他们寻找帮助,有什么方案届时告诉你
iamseason 2013-12-30
  • 打赏
  • 举报
回复
周一早上顶起
Eric沈 2013-12-30
  • 打赏
  • 举报
回复
同求啊,使用X509Certificate cert = new X509Certificate(path, psw, X509KeyStorageFlags.MachineKeySet); 这样获取,就报错, 未处理System.Security.Cryptography.CryptographicException Message=找不到申请的对象。 Source=mscorlib StackTrace: 在 System.Security.Cryptography.CryptographicException.ThrowCryptogaphicException(Int32 hr) 在 System.Security.Cryptography.X509Certificates.X509Utils._QueryCertFileType(String fileName) 在 System.Security.Cryptography.X509Certificates.X509Certificate.LoadCertificateFromFile(String fileName, Object password, X509KeyStorageFlags keyStorageFlags) 在 System.Security.Cryptography.X509Certificates.X509Certificate..ctor(String fileName, String password, X509KeyStorageFlags keyStorageFlags) 在 UnionMallSync.ICBC.ICBCApi.DoGet(String posdata) 位置 d:\EricSource\TIGER\Eshop2010.root\UnionMall\Projects\UnionMallSync\ICBC\ICBCApi.cs:行号 151 在 UnionMallSync.ICBC.ICBCApi.apiclick(String method, String data) 位置 d:\EricSource\TIGER\Eshop2010.root\UnionMall\Projects\UnionMallSync\ICBC\ICBCApi.cs:行号 130 在 UnionMallSync.ICBC.ICBCOrder.test() 位置 d:\EricSource\TIGER\Eshop2010.root\UnionMall\Projects\UnionMallSync\ICBC\ICBCOrder.cs:行号 101 在 UnionMallPRO.test.button205_Click(Object sender, EventArgs e) 位置 d:\EricSource\TIGER\Eshop2010.root\UnionMall\Projects\UnionMallPRO\test.cs:行号 2398 在 System.Windows.Forms.Control.OnClick(EventArgs e) 在 System.Windows.Forms.Button.OnClick(EventArgs e) 在 System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) 在 System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) 在 System.Windows.Forms.Control.WndProc(Message& m) 在 System.Windows.Forms.ButtonBase.WndProc(Message& m) 在 System.Windows.Forms.Button.WndProc(Message& m) 在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) 在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) 在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) 在 System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg) 在 System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData) 在 System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) 在 System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) 在 System.Windows.Forms.Application.Run(Form mainForm) 在 UnionMallPRO.Program.Main() 位置 d:\EricSource\TIGER\Eshop2010.root\UnionMall\Projects\UnionMallPRO\Program.cs:行号 17 在 System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args) 在 System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) 在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() 在 System.Threading.ThreadHelper.ThreadStart_Context(Object state) 在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) 在 System.Threading.ThreadHelper.ThreadStart() InnerException:
iamseason 2013-12-26
  • 打赏
  • 举报
回复
谢谢楼上,一般证书是pfx格式的,但是他提供的是truststore后缀的。没有遇到过。有了解的大侠吗?
iamseason 2013-12-26
  • 打赏
  • 举报
回复
大侠们都没起么?昨晚太累?
likofans 2013-12-25
  • 打赏
  • 举报
回复
你可以看看这个,http://q.cnblogs.com/q/54288/
iamseason 2013-12-25
  • 打赏
  • 举报
回复
对方给的实例都是java的,网上资料很少。

110,565

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧