Manage Assemblies
Manage Application
Strong Name Create a file: –sn -k a.snk View public key information: –sn -tp a.snk Install file in a CSP Container: –sn –i a.snk contname Attributes: –[assembly: AssemblyKeyFile("c:\\a.snk")] –[assembly: AssemblyKeyName("contname")] –[assembly: AssemblyVersion(" ")] Create a file: –sn -k a.snk View public key information: –sn -tp a.snk Install file in a CSP Container: –sn –i a.snk contname Attributes: –[assembly: AssemblyKeyFile("c:\\a.snk")] –[assembly: AssemblyKeyName("contname")] –[assembly: AssemblyVersion(" ")]
Configure application assemblies
Publisher policy file Create config file for the assembly redirect from ver to Save the file c1.dll.config Run: al /link:c1.dll.config /out:policy.1.0.c1.dll /keyfile:c:\a.snk Add the dll to the GAC Create config file for the assembly redirect from ver to Save the file c1.dll.config Run: al /link:c1.dll.config /out:policy.1.0.c1.dll /keyfile:c:\a.snk Add the dll to the GAC
Delay sign Sn –k a.snk Sn –p a.snk public.snk Add attributes: –[assembly: AssemblyDelaySign(true)] –[assembly: AssemblyKeyFile("c:\\public.snk")] Build the dll Create client application Sn –vr file.dll After testing: –Sn –R file.dll fullkeys.snk –Sn –Vu file.dll Sn –k a.snk Sn –p a.snk public.snk Add attributes: –[assembly: AssemblyDelaySign(true)] –[assembly: AssemblyKeyFile("c:\\public.snk")] Build the dll Create client application Sn –vr file.dll After testing: –Sn –R file.dll fullkeys.snk –Sn –Vu file.dll
Multi files assemblies csc /t:module a.cs csc /t:module b.cs al /out:multi.dll /t:library a.netmodule b.netmodule csc /t:module a.cs csc /t:module b.cs al /out:multi.dll /t:library a.netmodule b.netmodule
Digitally Sign code Testing purpose only: Makecert –sv a.pvk test.cer cert2spc test.cer test.spc signcode -spc test.spc -v a.pvk C.exe Testing purpose only: Makecert –sv a.pvk test.cer cert2spc test.cer test.spc signcode -spc test.spc -v a.pvk C.exe
Digitally Sign Code Real example: Ask for Software Publisher Certificate: –Goto –request a new certificate –choose Advanced request –choose Submit a certificate request to this CA using a form – fill the form intended purpose: code signing certificate mark "Mark keys as exportable" mark "Export keys to file" type filename for example s2.pvk Real example: Ask for Software Publisher Certificate: –Goto –request a new certificate –choose Advanced request –choose Submit a certificate request to this CA using a form – fill the form intended purpose: code signing certificate mark "Mark keys as exportable" mark "Export keys to file" type filename for example s2.pvk
download the cert copy the pvk file in the command prompt: –cert2spc certnew.cer testSPC.spc –signcode -spc TestSPC.spc -v s2.pvk w6.exe download the cert copy the pvk file in the command prompt: –cert2spc certnew.cer testSPC.spc –signcode -spc TestSPC.spc -v s2.pvk w6.exe Continue…
Load the file To test the certificate: X509Certificate x=X509Certificate.CreateFromSignedFile("cl1.dll"); MessageBox.Show(x.GetIssuerName()); MessageBox.Show(x.GetPublicKeyString()); To test the certificate: X509Certificate x=X509Certificate.CreateFromSignedFile("cl1.dll"); MessageBox.Show(x.GetIssuerName()); MessageBox.Show(x.GetPublicKeyString());