0

我使用托管在 Windows 上的 WCF 服务使用电子令牌进行数字签名

电子令牌强制弹出用户名和密码,这在 Windows 应用程序中是可能的,但在服务中,它会抛出错误,因为它无法在 “lcWriteBytes = loCryptoTest.OpaqueSignBytes(lcReadByte);”处提示弹出。

有没有办法让窗口通过服务弹出

这是我的代码:

namespace CryptService
{

    public partial class Service1 : ServiceBase
    {

        Chilkat.Crypt2 loCryptoTest;
        Chilkat.Cert locertTest = null;

        public Service1()
        {

            InitializeComponent();
            loCryptoTest = new Chilkat.Crypt2();
            loCryptoTest.UnlockComponent("key for unlocking");
            locertTest = new Chilkat.Cert();
            bool lbsuccess = locertTest.LoadByCommonName("certificate name");

            if ((lbsuccess != true))
            {
                MessageBox.Show("Failure loading cert");
            }

            loCryptoTest.SetSigningCert(locertTest);
            byte[] lcWriteBytes = null;
            byte[] lcReadByte = loCryptoTest.ReadFile(@"D:\Test\Input.htm");
            lcWriteBytes = loCryptoTest.OpaqueSignBytes(lcReadByte);
            lcReadByte = loCryptoTest.ReadFile(@"D:\Test\Input.htm");
            lcWriteBytes = loCryptoTest.OpaqueSignBytes(lcReadByte);

            if (lcWriteBytes.Length == 0)
            {
                MessageBox.Show("Opeque Signature Error");
            }
            loCryptoTest.WriteFile(@"D:\Test\InputCrypt.htm", lcWriteBytes);
            lcReadByte = null;
            lcWriteBytes = null;
        }
    }
}
4

0 回答 0