c# - Cryptographic Licensing Module not working from website? -


we have developed small method pulls cryptographic key signed xml document , checks signature using signedxml.checksignature method.

when run command line app key validates properly. call web app stops working. know happening?:

    // verify signature of xml file against asymmetric      // algorithm , return result.xmldocument doc, rsa key     public static boolean verifylicencefile(string xmllicfilepatharg)     {         bool isverified = false;          try         {              cspparameters cspparams = new cspparameters();             cspparams.keycontainername = containername;              rsacryptoserviceprovider rsakey = new rsacryptoserviceprovider(cspparams);              // create new xml document.             xmldocument xmldoc = new xmldocument();              // load xml file xmldocument object.             xmldoc.preservewhitespace = true;             xmldoc.load(xmllicfilepatharg);               // check arguments.             if (xmldoc == null)                 throw new argumentexception("doc");             if (rsakey == null)                 throw new argumentexception("key");              // create new signedxml object , pass             // xml document class.             signedxml signedxml = new signedxml(xmldoc);              // find "signature" node , create new             // xmlnodelist object.             xmlnodelist nodelist = xmldoc.getelementsbytagname("signature");              // throw exception if no signature found.             if (nodelist.count <= 0)             {                 throw new cryptographicexception("verification failed: no signature found in document.");             }              // example supports 1 signature             // entire xml document.  throw exception              // if more 1 signature found.             if (nodelist.count >= 2)             {                 throw new cryptographicexception("verification failed: more 1 signature found document.");             }              // load first <signature> node.               signedxml.loadxml((xmlelement)nodelist[0]);              // check signature , return result.             isverified = signedxml.checksignature(rsakey);         }         catch (exception ex)         {          }          return isverified;      } 

i guess webserver runs user command-line tool. unless use cspproviderflags.usemachinekeystore cspparameters default using user key-store. rsacryptoserviceprovider silently generate new key if specified key-container not exist, result code uses different key verify when running in web-server when running the command-line.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -