构建一个web方式的局域网签名

当需要大量签名的工作,同时又多用户使用,但又想把签名证书进行一定限制时,下面就实现了这样一个简单的方案。 

需要一台IIS server, 共享一个文件夹(读写)。

在IIS 上创建一个asp.net web站点:

页面上添加一个按钮就可以了,后台代码如下:

 

using  System;
using  System.Data;
using  System.Configuration;
using  System.Web;
using  System.Web.Security;
using  System.Web.UI;
using  System.Web.UI.WebControls;
using  System.Web.UI.WebControls.WebParts;
using  System.Web.UI.HtmlControls;
using  System.Diagnostics;
using  System.Timers;

public   partial   class  _Default : System.Web.UI.Page 
{
    
protected   void  Page_Load( object  sender, EventArgs e)
    {

    }
    
void  processSign( string  cmd,  string  showstr)
    {
       
// 利用CMD来执行已经写好的sign的bat处理文件
        Process p  =   new  Process(); 
        p.StartInfo.RedirectStandardOutput 
=   true ;
        p.StartInfo.FileName 
=   " cmd.exe " ;
        p.StartInfo.WorkingDirectory 
=   @" C:doxtechsign " ;
        p.StartInfo.UseShellExecute 
=   false ;
        p.StartInfo.RedirectStandardInput 
=   true ;
        p.StartInfo.RedirectStandardOutput 
=   true ;
        p.StartInfo.RedirectStandardError 
=   true ;
        p.StartInfo.CreateNoWindow 
=   true ;
        p.Start();
        
// 记录签名者IP地址 和 签名的一些信息(这里仅仅反馈给用户显示),如果保存至文件就可以进行管理了。
         string  cIP  =  Request.ServerVariables[ " REMOTE_ADDR " ];
        p.StandardInput.WriteLine(cmd 
+   "   "   +  cIP);
        p.StandardInput.WriteLine(
" exit " );
        
string  info  =   " Your IP:  "   +  cIP  +   " <br> Using Signature is  "   +  showstr  +   " <br><br> " ;
        
string  starstr  =  p.StandardOutput.ReadToEnd();
        
string [] sc  =   new   string [] {  " "  };
        
string [] showmsg  =  starstr.Split(sc, StringSplitOptions.RemoveEmptyEntries);
        System.DateTime currentTime 
=   new  System.DateTime();
        currentTime 
=  System.DateTime.Now;
        
string  Labelstr  =   " Sign Time:  "   +  currentTime.ToString( " g " +   " <br> "   +  info;
        
if  (showmsg.Length  <=   4 )
        {
            Labelstr 
+=  ( " Not Found Files! <br> " );
            Label1.Text 
=  Labelstr;
            
return ;
        }
        
else
        {
            
for  ( int  i  =   3 ; i  <  showmsg.Length  -   1 ; i ++ )
            {
                Labelstr 
+=  showmsg[i];
                Labelstr 
+=   " <br> " ;

            }

            Label1.Text 
=  Labelstr  +   " <br> " ;

        }
    }

    
protected   void  Button2_Click( object  sender, EventArgs e)
    {
        processSign(
" Sign2K3.bat " " File -> Windows Mobile 2003 " );

    }
}

Sign2K3.bat 文件:

 

@echo off
dir Files | find /i 
" mui "  >signname.tmp
dir Files | find /i 
" dll "  >>signname.tmp
dir Files | find /i 
" cab "  >>signname.tmp
dir Files | find /i 
" exe "  >>signname.tmp
dir Files | find /i 
" hme "  >>signname.tmp

for /f 
" tokens=4 "  %%a in (signname.tmp) do signcode /spc DOXTechsign.cer /v DOXTechsign.pvk /a sha1 Files%%a
del signname.tmp
goto done

:usage
echo S
echo filename: all mui
, dll , exe files in the files floder

:done

 

 

这样就构建完成了。

1.当需要签名是在客户端上打开网页。2. 把需要签名的文件放置在共享的文件里。 3. 点击页面上的按钮。

在这里,只是并没有深入考虑安全性和广域网,也忽略多用户同时进行处理。简单安全性可以使用IIS提供安全设置来控制指定用户密码登入此网页,限制IP等。广域网的实施那就要实现页面上传文件至服务器,签名后下载至客户端。

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值