示例#1
0
        public void InitContext()
        {
            this.hexConverter = new HexConverter();
            this.byteWorker = new ByteWorker();

            //KMS參數設定
            kms_context_param_t ctx_param = new kms_context_param_t();
            ctx_param.app_name = "kms2Test";
            ctx_param.kms_server = //@"http://10.27.68.163:8080/eGATEsKMS/interface";
                @"http://127.0.0.1:8081/eGATEsKMS/interface";
            ctx_param.ssl = 0;
            ctx_param.debug = 1;
            ctx_param.timeout = 30;
            ctx_param.connect_timeout = 10;
            ctx_param.auth_with_cipher = 1;
            //DLL要在X64下跑,所以編譯的設定都改成x64和容許UnSafe程式碼(因DLL是C++寫的),測試設定的預設處理器架構也要改x64
            this.esKmsApi = EsKmsApi.GetInstance(ctx_param);
        }
示例#2
0
 public static EsKmsApi GetInstance(kms_context_param_t ctx_param)
 {
     uint r = 0;
     uint out_ctx = 0;
     Debug.WriteLine("Begin GetInstance ...");
     //load eskmsApi.dll
     try
     {
         r = kms_context_create(ref out_ctx, ref ctx_param);
         if (r != 0)
         {
             Debug.WriteLine(String.Format("eskmsapi error: 0x{0:X8}", r));
             throw new Exception(String.Format("eskmsapi error: 0x{0:X8}", r));
         }
     }
     catch (Exception ex)
     {
         var qq = ex;
     }
     Debug.WriteLine(String.Format("End GetInstance:[{0:X8}]", r));
     EsKmsApi kmsapi = new EsKmsApi();
     kmsapi.ctx = out_ctx;
     return kmsapi;
 }