QuestionIObjectSafety - ActiveX Authenticode problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Nevalon
    New Member
    • Dec 2010
    • 1

    QuestionIObjectSafety - ActiveX Authenticode problem

    Hello,

    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:
    Code:
    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
      }
    }
    I am not generating a CAB file, just a DLL. I am signing that DLL with Authenticode, and next registering it by register.bat:

    C:\WINDOWS\Micr osoft.NET\Frame work\v2.0.50727/regasm /tlb /codebase ActiveX_MyProgr am.dll

    Hosting in HTML:
    Code:
    <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>
    The control works with no problem, but still shows the security tab before loading. Any idea?

    Thanks in advance.
Working...