惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Y
Y Combinator Blog
S
SegmentFault 最新的问题
Engineering at Meta
Engineering at Meta
量子位
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Google DeepMind News
Google DeepMind News
博客园_首页
云风的 BLOG
云风的 BLOG
月光博客
月光博客
I
InfoQ
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Vercel News
Vercel News
美团技术团队
Microsoft Security Blog
Microsoft Security Blog
P
Proofpoint News Feed
D
Docker
F
Fortinet All Blogs
N
Netflix TechBlog - Medium
博客园 - 叶小钗
Martin Fowler
Martin Fowler
雷峰网
雷峰网
酷 壳 – CoolShell
酷 壳 – CoolShell
J
Java Code Geeks
Microsoft Azure Blog
Microsoft Azure Blog

博客园 - 木头's

.Net读取数字证书信息和扩展域信息 APACHE2.0 TOMCAT5.0 SSL 配置 smimedecryptvbs Using CAPICOM to obtain an SSL Certificate .NET and Certificate Stores net平台下的数字签名技术的讲解 java数字签名(签名生成,用证书验证签名) Apache安全应用资源文档 国外PKI/CA体系发展状况 CA基本常识:X.509标准 - 木头's - 博客园 PKI体系的十大风险 在职必看!受益无穷的28条职场语录 启用客户端证书并在 SharePoint Portal Server 2003 的内容搜索中使用客户端证书 一个基于RSA算法的Java数字签名例子 实现在 Linux 下 Tomcat 的双向SSL认证 JAVA对数字证书的常用操作 一组数据摘要算法的效率测试 一首歌曲,一种心情 职场必读
ASP.NET, Javascript tips: Encrypt /Sign /Verify signed me...
木头's · 2007-08-16 · via 博客园 - 木头's

This demonstrates possibilities on encrypting, signing, verifying message using the Capicom ActiveX and javascript in a webbrowser. An ASP.NET developers can take note of this technique when you want to invoke to capicom dll to implement PKI infastructure using a browser. I know .NET SmartClient would have been another option where you can use the .NET Framework Libraries to deal with X509Certificates, but you might want to know this technique too:

Source Blog: http://www.feed-squirrel.com/index.cfm?evt=viewItem&ID=36269

  • Use a Memory store and in a web page signs and verifies the sign
  • Create an VB ActiveX with the following code and register it. Also, the CAPICOM dll must be registered. Both activeX could be downloaded from a web site)
  • This code imports a PKCS#12 issued by a subordinader CA. If you want to get it contact me.

Function sign(text As String, P12Path As String, P12Password As String) As String

   ' This function imports a PKCS#12 container (private key and certificate to a
   ' memory store

    Dim store As store
    Dim signedData As signedData
    Dim signer As signer

    Set signer = New signer
    Set signedData = New signedData
    Set store = New store

    store.Open CAPICOM_MEMORY_STORE, "My", CAPICOM_STORE_OPEN_READ_WRITE
    store.Load P12Path, P12Password, CAPICOM_KEY_STORAGE_DEFAULT

    signedData.Content = text
    signer.Certificate = store.Certificates.Item(1)

    szSignedData = signedData.sign(signer, True, CAPICOM_ENCODE_BASE64)
    sign = szSignedData
End Function

  • Create a Web Page with the following javascript functions, invoking those from buttons

function btnSignedData_OnClick()
  {
    var SignedData = new ActiveXObject("AutomaticSign.ASign");

  try
  {
   txtSignedData.value = SignedData.Sign(txtPlainText.value,"c:\\c.p12","1111");
  }
  catch (e)
  {
   alert("An error occurred when attempting to sign the content);
   return false;
  }
  }
  function btnVerifyData_OnClick()
   {
    var CAPICOM_CERT_INFO_SUBJECT_SIMPLE_NAME = 0;
    var CAPICOM_CERT_INFO_ISSUER_SIMPLE_NAME = 1; 
    var CAPICOM_VERIFY_SIGNATURE_ONLY = 0;
   // instantiate the CAPICOM objects
   var certificate = new ActiveXObject('CAPICOM.Certificate');
   var SignedData = new ActiveXObject('CAPICOM.SignedData');
   try
   {
    SignedData.Content=txtPlainText.value;
   SignedData.Verify(txtSignedData.value, true, CAPICOM_VERIFY_SIGNATURE_ONLY);
   certificate=SignedData.Certificates(2);
    txtSignerData.value="Certificate :" + certificate.GetInfo(CAPICOM_CERT_INFO_SUBJECT_SIMPLE_NAME) + "\n";
    txtSignerData.value+= "Issuer     :" + certificate.GetInfo(CAPICOM_CERT_INFO_ISSUER_SIMPLE_NAME);
   }
   catch (e)
   {
    alert(e.description);
    return false;
   }
  alert("Signature verified");
 }