I have to implement Authenticode certyficate for my ActiveX control written in C# (WPF).
My ActiveX control works fine, but IE always shows a security bar, user has to click "Allow" each time he runs the control - This is the reason, why we have dicded to buy Authenticode Certyficate. We have received a certyficate and private key, but after signing the control (signing process end correctly) it is still not "safe" for IE.
I have found information, that I have to implement IObjectSafety interface, but it also does not made any change. I will post You code fragments:
Expand|Select|Wrap|Line Numbers
- namespace ActiveX_MyProgram
- {
- [Guid("694D1820-04B6-4388-928F-FF858B95F880")]
- public interface iMyProgram
- {
- //some code here, not important for my question
- }
- [Guid("68FD4E0D-D7BC-4cf6-BEB7-CFF950161A79")]
- [InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
- public interface iMyProgramEvents
- {
- //some code here, not important for my question
- }
- [ComImport()]
- [GuidAttribute("CB5BDC81-93C1-11CF-8F20-00805F2CD064")]
- [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
- public interface IObjectSafety
- {
- [PreserveSig]
- int GetInterfaceSafetyOptions(ref Guid riid,
- out int pdwSupportedOptions,
- out int pdwEnabledOptions);
- [PreserveSig()]
- int SetInterfaceSafetyOptions(ref Guid riid,
- int dwOptionSetMask,
- int dwEnabledOptions);
- }
- [ProgId("ActiveX_MyProgram")]
- [ClassInterface(ClassInterfaceType.None), ComSourceInterfaces(typeof(iMyProgramEvents))]
- [Guid("6BAE3EB8-EBC9-11DE-A7A1-0A6F55F89593")]
- [ComVisible(true)]
- public partial class Acx : UserControl, iMyProgram, IObjectSafety
- {
- /* Some more implementation, that I have cutted out... */
- #region IObjectSafety implementation
- private const int INTERFACESAFE_FOR_UNTRUSTED_CALLER = 0x00000001;
- private const int INTERFACESAFE_FOR_UNTRUSTED_DATA = 0x00000002;
- private const int S_OK = 0;
- int IObjectSafety.GetInterfaceSafetyOptions(ref Guid riid, out int pdwSupportedOptions, out int pdwEnabledOptions)
- {
- pdwSupportedOptions = INTERFACESAFE_FOR_UNTRUSTED_CALLER | INTERFACESAFE_FOR_UNTRUSTED_DATA;
- pdwEnabledOptions = INTERFACESAFE_FOR_UNTRUSTED_CALLER | INTERFACESAFE_FOR_UNTRUSTED_DATA;
- return S_OK; // return S_OK
- }
- int IObjectSafety.SetInterfaceSafetyOptions(ref Guid riid, int dwOptionSetMask, int dwEnabledOptions)
- {
- return S_OK; // return S_OK
- }
- #endregion
- }
- }
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727/regasm /tlb /codebase ActiveX_MyProgram.dll
Hosting in HTML:
Expand|Select|Wrap|Line Numbers
- <html><br/>
- <body color=white><br/>
- <hr/> <br/>
- <font face=arial size=1><br/>
- <OBJECT id="ACX" name="ACX" classid="clsid:6BAE3EB8-EBC9-11DE-A7A1-0A6F55F89593" VIEWASTEXT codebase="ACX.cab" width=1900 height=1000></OBJECT><br/>
- </font> <br/>
- </body><br/>
- </html>
Thanks in advance.