public static void DeleteCertMonitor(CertificateOperations certOps, ITestOutputHelper testOutputHelper, string thumbAlgo, string thumb)
        {
            bool found;

            testOutputHelper.WriteLine("polling for deletion of thumbprint: " + thumb);

            do
            {
                found = false;

                foreach (Certificate curCert in certOps.ListCertificates())
                {
                    if (thumbAlgo.Equals(curCert.ThumbprintAlgorithm, StringComparison.InvariantCultureIgnoreCase) &&
                        thumb.Equals(curCert.Thumbprint, StringComparison.InvariantCultureIgnoreCase))
                    {
                        testOutputHelper.WriteLine("DeleteCertMonitor: thumb " + curCert.Thumbprint + ", state: " + curCert.State);

                        found = true;

                        break;
                    }
                }

                if (found)
                {
                    System.Threading.Thread.Sleep(5000);
                }
            }while (found);
        }
        /// <summary>
        /// Deletes the specified certificate.
        /// </summary>
        /// <param name="parameters">The parameters indicating which certificate to delete.</param>
        public void DeleteCertificate(CertificateOperationParameters parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }

            CertificateOperations certOperations = parameters.Context.BatchOMClient.CertificateOperations;

            certOperations.DeleteCertificate(parameters.ThumbprintAlgorithm, parameters.Thumbprint, parameters.AdditionalBehaviors);
        }
        /// <summary>
        /// Cancels a failed deletion of the specified certificate.
        /// </summary>
        /// <param name="parameters">The parameters indicating which certificate to failed to delete.</param>
        public void CancelDeleteCertificate(CertificateOperationParameters parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }

            WriteVerbose(string.Format(Resources.CancelCertificateDelete, parameters.Thumbprint));
            CertificateOperations certOperations = parameters.Context.BatchOMClient.CertificateOperations;

            certOperations.CancelDeleteCertificate(parameters.ThumbprintAlgorithm, parameters.Thumbprint, parameters.AdditionalBehaviors);
        }
        private void IBackgroundWorkerC_DoWork(object sender, DoWorkEventArgs e)
        {
            string LStrServerHost      = string.Empty;
            bool   LBoolDownloaded     = false;
            bool   LBoolInstalled      = false;
            string LStrCertificateFile = string.Empty;
            string LStrCallReturn      = string.Empty;

            try
            {
                LBoolDownloaded = CertificateOperations.DownloadCertificate(IListConnectInfo[0], IListConnectInfo[1], "UMP.S." + IListConnectInfo[0] + ".pfx", ref LStrCallReturn);
                if (!LBoolDownloaded)
                {
                    I00003OperationReturn.BoolReturn   = false;
                    I00003OperationReturn.StringReturn = LStrCallReturn;
                    return;
                }
                LStrCertificateFile = LStrCallReturn;
                e.Result            = LStrCertificateFile;

                if (!IBoolInRoot)
                {
                    LBoolInstalled = CertificateOperations.InstallCertificate(LStrCertificateFile, "VoiceCyber,123", StoreName.Root, StoreLocation.LocalMachine, ref LStrCallReturn);
                    if (!LBoolInstalled)
                    {
                        I00003OperationReturn.BoolReturn   = false;
                        I00003OperationReturn.StringReturn = LStrCallReturn;
                        return;
                    }
                }

                if (!IBoolInTrustedPublisher)
                {
                    LBoolInstalled = CertificateOperations.InstallCertificate(LStrCertificateFile, "VoiceCyber,123", StoreName.TrustedPublisher, StoreLocation.LocalMachine, ref LStrCallReturn);
                    if (!LBoolInstalled)
                    {
                        I00003OperationReturn.BoolReturn   = false;
                        I00003OperationReturn.StringReturn = LStrCallReturn;
                        return;
                    }
                }
            }
            catch (Exception ex)
            {
                I00003OperationReturn.BoolReturn   = false;
                I00003OperationReturn.StringReturn = "UMP001E003" + App.GStrSpliterChar + ex.Message;
            }
        }
Exemple #5
0
 /// <summary>
 /// Initializes client properties.
 /// </summary>
 private void Initialize()
 {
     BatchAccount              = new BatchAccountOperations(this);
     ApplicationPackage        = new ApplicationPackageOperations(this);
     Application               = new ApplicationOperations(this);
     Location                  = new LocationOperations(this);
     Operations                = new Operations(this);
     Certificate               = new CertificateOperations(this);
     PrivateLinkResource       = new PrivateLinkResourceOperations(this);
     PrivateEndpointConnection = new PrivateEndpointConnectionOperations(this);
     Pool           = new PoolOperations(this);
     BaseUri        = new System.Uri("https://management.azure.com");
     ApiVersion     = "2020-09-01";
     AcceptLanguage = "en-US";
     LongRunningOperationRetryTimeout = 30;
     GenerateClientRequestId          = true;
     SerializationSettings            = new JsonSerializerSettings
     {
         Formatting            = Newtonsoft.Json.Formatting.Indented,
         DateFormatHandling    = Newtonsoft.Json.DateFormatHandling.IsoDateFormat,
         DateTimeZoneHandling  = Newtonsoft.Json.DateTimeZoneHandling.Utc,
         NullValueHandling     = Newtonsoft.Json.NullValueHandling.Ignore,
         ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize,
         ContractResolver      = new ReadOnlyJsonContractResolver(),
         Converters            = new List <JsonConverter>
         {
             new Iso8601TimeSpanConverter()
         }
     };
     SerializationSettings.Converters.Add(new TransformationJsonConverter());
     DeserializationSettings = new JsonSerializerSettings
     {
         DateFormatHandling    = Newtonsoft.Json.DateFormatHandling.IsoDateFormat,
         DateTimeZoneHandling  = Newtonsoft.Json.DateTimeZoneHandling.Utc,
         NullValueHandling     = Newtonsoft.Json.NullValueHandling.Ignore,
         ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize,
         ContractResolver      = new ReadOnlyJsonContractResolver(),
         Converters            = new List <JsonConverter>
         {
             new Iso8601TimeSpanConverter()
         }
     };
     CustomInitialize();
     DeserializationSettings.Converters.Add(new TransformationJsonConverter());
     DeserializationSettings.Converters.Add(new CloudErrorJsonConverter());
 }
 /// <summary>
 /// Initializes client properties.
 /// </summary>
 private void Initialize()
 {
     Application                      = new ApplicationOperations(this);
     Pool                             = new PoolOperations(this);
     Account                          = new AccountOperations(this);
     Job                              = new JobOperations(this);
     Certificate                      = new CertificateOperations(this);
     File                             = new FileOperations(this);
     JobSchedule                      = new JobScheduleOperations(this);
     Task                             = new TaskOperations(this);
     ComputeNode                      = new ComputeNodeOperations(this);
     ComputeNodeExtension             = new ComputeNodeExtensionOperations(this);
     BaseUri                          = "{batchUrl}";
     ApiVersion                       = "2021-06-01.14.0";
     AcceptLanguage                   = "en-US";
     LongRunningOperationRetryTimeout = 30;
     GenerateClientRequestId          = true;
     SerializationSettings            = new JsonSerializerSettings
     {
         Formatting            = Newtonsoft.Json.Formatting.Indented,
         DateFormatHandling    = Newtonsoft.Json.DateFormatHandling.IsoDateFormat,
         DateTimeZoneHandling  = Newtonsoft.Json.DateTimeZoneHandling.Utc,
         NullValueHandling     = Newtonsoft.Json.NullValueHandling.Ignore,
         ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize,
         ContractResolver      = new ReadOnlyJsonContractResolver(),
         Converters            = new List <JsonConverter>
         {
             new Iso8601TimeSpanConverter()
         }
     };
     DeserializationSettings = new JsonSerializerSettings
     {
         DateFormatHandling    = Newtonsoft.Json.DateFormatHandling.IsoDateFormat,
         DateTimeZoneHandling  = Newtonsoft.Json.DateTimeZoneHandling.Utc,
         NullValueHandling     = Newtonsoft.Json.NullValueHandling.Ignore,
         ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize,
         ContractResolver      = new ReadOnlyJsonContractResolver(),
         Converters            = new List <JsonConverter>
         {
             new Iso8601TimeSpanConverter()
         }
     };
     CustomInitialize();
     DeserializationSettings.Converters.Add(new CloudErrorJsonConverter());
 }
        /// <summary>
        /// Lists the certificates matching the specified filter options.
        /// </summary>
        /// <param name="options">The options to use when querying for certificates.</param>
        /// <returns>The certificates matching the specified filter options.</returns>
        public IEnumerable <PSCertificate> ListCertificates(ListCertificateOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException("options");
            }

            // Get the single certificate matching the specified thumbprint
            if (!string.IsNullOrWhiteSpace(options.Thumbprint))
            {
                WriteVerbose(string.Format(Resources.GetCertificateByThumbprint, options.Thumbprint));
                CertificateOperations certOperations = options.Context.BatchOMClient.CertificateOperations;
                ODATADetailLevel      getDetailLevel = new ODATADetailLevel(selectClause: options.Select);
                Certificate           certificate    = certOperations.GetCertificate(options.ThumbprintAlgorithm, options.Thumbprint,
                                                                                     detailLevel: getDetailLevel, additionalBehaviors: options.AdditionalBehaviors);
                PSCertificate psCertificate = new PSCertificate(certificate);
                return(new PSCertificate[] { psCertificate });
            }
            // List certificates using the specified filter
            else
            {
                string           verboseLogString = null;
                ODATADetailLevel listDetailLevel  = new ODATADetailLevel(selectClause: options.Select);
                if (!string.IsNullOrEmpty(options.Filter))
                {
                    verboseLogString             = Resources.GetCertificatesByFilter;
                    listDetailLevel.FilterClause = options.Filter;
                }
                else
                {
                    verboseLogString = Resources.GetCertificatesNoFilter;
                }
                WriteVerbose(verboseLogString);

                CertificateOperations             certOperations  = options.Context.BatchOMClient.CertificateOperations;
                IPagedEnumerable <Certificate>    certificates    = certOperations.ListCertificates(listDetailLevel, options.AdditionalBehaviors);
                Func <Certificate, PSCertificate> mappingFunction = c => { return(new PSCertificate(c)); };
                return(PSPagedEnumerable <PSCertificate, Certificate> .CreateWithMaxCount(
                           certificates, mappingFunction, options.MaxCount, () => WriteVerbose(string.Format(Resources.MaxCount, options.MaxCount))));
            }
        }
        private void IBackgroundWorkerB_DoWork(object sender, DoWorkEventArgs e)
        {
            string LStrServerHost    = string.Empty;
            string LStrCerHashString = string.Empty;
            string LStrCallReturn    = string.Empty;

            try
            {
                IBoolInRoot = false; IBoolInTrustedPublisher = false;
                string[] LStrOperationReturn = I00003OperationReturn.StringReturn.Split(App.GStrSpliterChar.ToCharArray());
                LStrServerHost    = LStrOperationReturn[0];
                LStrCerHashString = LStrOperationReturn[1];

                IBoolInRoot = CertificateOperations.CertificateIsExist(LStrServerHost, LStrCerHashString, StoreName.Root, StoreLocation.LocalMachine, ref LStrCallReturn);
                if (!IBoolInRoot)
                {
                    if (!string.IsNullOrEmpty(LStrCallReturn))
                    {
                        I00003OperationReturn.BoolReturn   = false;
                        I00003OperationReturn.StringReturn = LStrCallReturn;
                        return;
                    }
                }
                IBoolInTrustedPublisher = CertificateOperations.CertificateIsExist(LStrServerHost, LStrCerHashString, StoreName.TrustedPublisher, StoreLocation.LocalMachine, ref LStrCallReturn);
                if (!IBoolInTrustedPublisher)
                {
                    if (!string.IsNullOrEmpty(LStrCallReturn))
                    {
                        I00003OperationReturn.BoolReturn   = false;
                        I00003OperationReturn.StringReturn = LStrCallReturn;
                        return;
                    }
                }
            }
            catch (Exception ex)
            {
                I00003OperationReturn.BoolReturn   = false;
                I00003OperationReturn.StringReturn = "UMP001E002" + App.GStrSpliterChar + ex.Message;
            }
        }
        /// <summary>
        /// Adds a certificate to the specified Batch account.
        /// </summary>
        /// <param name="parameters">The parameters to use when creating the certificate.</param>
        public void AddCertificate(NewCertificateParameters parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }

            CertificateOperations certOperations = parameters.Context.BatchOMClient.CertificateOperations;
            Certificate           unboundCert;

            if (!string.IsNullOrWhiteSpace(parameters.FilePath))
            {
                if (string.IsNullOrWhiteSpace(parameters.Password))
                {
                    unboundCert = certOperations.CreateCertificate(parameters.FilePath);
                }
                else
                {
                    unboundCert = certOperations.CreateCertificate(parameters.FilePath, parameters.Password);
                }
            }
            else
            {
                if (string.IsNullOrWhiteSpace(parameters.Password))
                {
                    unboundCert = certOperations.CreateCertificate(parameters.RawData);
                }
                else
                {
                    unboundCert = certOperations.CreateCertificate(parameters.RawData, parameters.Password);
                }
            }

            WriteVerbose(string.Format(Resources.AddingCertificate, unboundCert.Thumbprint));
            unboundCert.Commit(parameters.AdditionalBehaviors);
        }
 /// <summary>
 /// Initializes client properties.
 /// </summary>
 private void Initialize()
 {
     Policy                           = new PolicyOperations(this);
     PolicySnippets                   = new PolicySnippetsOperations(this);
     Regions                          = new RegionsOperations(this);
     Api                              = new ApiOperations(this);
     ApiRevisions                     = new ApiRevisionsOperations(this);
     ApiRelease                       = new ApiReleaseOperations(this);
     ApiOperation                     = new ApiOperationOperations(this);
     ApiOperationPolicy               = new ApiOperationPolicyOperations(this);
     ApiProduct                       = new ApiProductOperations(this);
     ApiPolicy                        = new ApiPolicyOperations(this);
     ApiSchema                        = new ApiSchemaOperations(this);
     ApiDiagnostic                    = new ApiDiagnosticOperations(this);
     ApiDiagnosticLogger              = new ApiDiagnosticLoggerOperations(this);
     ApiIssue                         = new ApiIssueOperations(this);
     ApiIssueComment                  = new ApiIssueCommentOperations(this);
     ApiIssueAttachment               = new ApiIssueAttachmentOperations(this);
     AuthorizationServer              = new AuthorizationServerOperations(this);
     Backend                          = new BackendOperations(this);
     Certificate                      = new CertificateOperations(this);
     ApiManagementOperations          = new ApiManagementOperations(this);
     ApiManagementServiceSkus         = new ApiManagementServiceSkusOperations(this);
     ApiManagementService             = new ApiManagementServiceOperations(this);
     Diagnostic                       = new DiagnosticOperations(this);
     DiagnosticLogger                 = new DiagnosticLoggerOperations(this);
     EmailTemplate                    = new EmailTemplateOperations(this);
     Group                            = new GroupOperations(this);
     GroupUser                        = new GroupUserOperations(this);
     IdentityProvider                 = new IdentityProviderOperations(this);
     Logger                           = new LoggerOperations(this);
     Notification                     = new NotificationOperations(this);
     NotificationRecipientUser        = new NotificationRecipientUserOperations(this);
     NotificationRecipientEmail       = new NotificationRecipientEmailOperations(this);
     NetworkStatus                    = new NetworkStatusOperations(this);
     OpenIdConnectProvider            = new OpenIdConnectProviderOperations(this);
     SignInSettings                   = new SignInSettingsOperations(this);
     SignUpSettings                   = new SignUpSettingsOperations(this);
     DelegationSettings               = new DelegationSettingsOperations(this);
     Product                          = new ProductOperations(this);
     ProductApi                       = new ProductApiOperations(this);
     ProductGroup                     = new ProductGroupOperations(this);
     ProductSubscriptions             = new ProductSubscriptionsOperations(this);
     ProductPolicy                    = new ProductPolicyOperations(this);
     Property                         = new PropertyOperations(this);
     QuotaByCounterKeys               = new QuotaByCounterKeysOperations(this);
     QuotaByPeriodKeys                = new QuotaByPeriodKeysOperations(this);
     Reports                          = new ReportsOperations(this);
     Subscription                     = new SubscriptionOperations(this);
     TagResource                      = new TagResourceOperations(this);
     Tag                              = new TagOperations(this);
     TagDescription                   = new TagDescriptionOperations(this);
     Operation                        = new OperationOperations(this);
     TenantAccess                     = new TenantAccessOperations(this);
     TenantAccessGit                  = new TenantAccessGitOperations(this);
     TenantConfiguration              = new TenantConfigurationOperations(this);
     User                             = new UserOperations(this);
     UserGroup                        = new UserGroupOperations(this);
     UserSubscription                 = new UserSubscriptionOperations(this);
     UserIdentities                   = new UserIdentitiesOperations(this);
     ApiVersionSet                    = new ApiVersionSetOperations(this);
     ApiExport                        = new ApiExportOperations(this);
     BaseUri                          = new System.Uri("https://management.azure.com");
     ApiVersion                       = "2018-01-01";
     AcceptLanguage                   = "en-US";
     LongRunningOperationRetryTimeout = 30;
     GenerateClientRequestId          = true;
     SerializationSettings            = new JsonSerializerSettings
     {
         Formatting            = Newtonsoft.Json.Formatting.Indented,
         DateFormatHandling    = Newtonsoft.Json.DateFormatHandling.IsoDateFormat,
         DateTimeZoneHandling  = Newtonsoft.Json.DateTimeZoneHandling.Utc,
         NullValueHandling     = Newtonsoft.Json.NullValueHandling.Ignore,
         ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize,
         ContractResolver      = new ReadOnlyJsonContractResolver(),
         Converters            = new List <JsonConverter>
         {
             new Iso8601TimeSpanConverter()
         }
     };
     SerializationSettings.Converters.Add(new TransformationJsonConverter());
     DeserializationSettings = new JsonSerializerSettings
     {
         DateFormatHandling    = Newtonsoft.Json.DateFormatHandling.IsoDateFormat,
         DateTimeZoneHandling  = Newtonsoft.Json.DateTimeZoneHandling.Utc,
         NullValueHandling     = Newtonsoft.Json.NullValueHandling.Ignore,
         ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize,
         ContractResolver      = new ReadOnlyJsonContractResolver(),
         Converters            = new List <JsonConverter>
         {
             new Iso8601TimeSpanConverter()
         }
     };
     CustomInitialize();
     DeserializationSettings.Converters.Add(new TransformationJsonConverter());
     DeserializationSettings.Converters.Add(new CloudErrorJsonConverter());
 }
 /// <summary>
 /// Initializes client properties.
 /// </summary>
 private void Initialize()
 {
     AutomationAccount = new AutomationAccountOperations(this);
     Operations        = new Operations(this);
     Statistics        = new StatisticsOperations(this);
     Usages            = new UsagesOperations(this);
     Keys                                   = new KeysOperations(this);
     Certificate                            = new CertificateOperations(this);
     Connection                             = new ConnectionOperations(this);
     ConnectionType                         = new ConnectionTypeOperations(this);
     Credential                             = new CredentialOperations(this);
     DscConfiguration                       = new DscConfigurationOperations(this);
     HybridRunbookWorkerGroup               = new HybridRunbookWorkerGroupOperations(this);
     JobSchedule                            = new JobScheduleOperations(this);
     LinkedWorkspace                        = new LinkedWorkspaceOperations(this);
     Activity                               = new ActivityOperations(this);
     Module                                 = new ModuleOperations(this);
     ObjectDataTypes                        = new ObjectDataTypesOperations(this);
     Fields                                 = new FieldsOperations(this);
     Schedule                               = new ScheduleOperations(this);
     Variable                               = new VariableOperations(this);
     Webhook                                = new WebhookOperations(this);
     Watcher                                = new WatcherOperations(this);
     SoftwareUpdateConfigurations           = new SoftwareUpdateConfigurationsOperations(this);
     SoftwareUpdateConfigurationRuns        = new SoftwareUpdateConfigurationRunsOperations(this);
     SoftwareUpdateConfigurationMachineRuns = new SoftwareUpdateConfigurationMachineRunsOperations(this);
     SourceControl                          = new SourceControlOperations(this);
     SourceControlSyncJob                   = new SourceControlSyncJobOperations(this);
     SourceControlSyncJobStreams            = new SourceControlSyncJobStreamsOperations(this);
     Job       = new JobOperations(this);
     JobStream = new JobStreamOperations(this);
     AgentRegistrationInformation = new AgentRegistrationInformationOperations(this);
     DscNode                          = new DscNodeOperations(this);
     NodeReports                      = new NodeReportsOperations(this);
     DscCompilationJob                = new DscCompilationJobOperations(this);
     DscCompilationJobStream          = new DscCompilationJobStreamOperations(this);
     DscNodeConfiguration             = new DscNodeConfigurationOperations(this);
     NodeCountInformation             = new NodeCountInformationOperations(this);
     RunbookDraft                     = new RunbookDraftOperations(this);
     Runbook                          = new RunbookOperations(this);
     TestJobStreams                   = new TestJobStreamsOperations(this);
     TestJob                          = new TestJobOperations(this);
     Python2Package                   = new Python2PackageOperations(this);
     BaseUri                          = new System.Uri("https://management.azure.com");
     AcceptLanguage                   = "en-US";
     LongRunningOperationRetryTimeout = 30;
     GenerateClientRequestId          = true;
     SerializationSettings            = new JsonSerializerSettings
     {
         Formatting            = Newtonsoft.Json.Formatting.Indented,
         DateFormatHandling    = Newtonsoft.Json.DateFormatHandling.IsoDateFormat,
         DateTimeZoneHandling  = Newtonsoft.Json.DateTimeZoneHandling.Utc,
         NullValueHandling     = Newtonsoft.Json.NullValueHandling.Ignore,
         ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize,
         ContractResolver      = new ReadOnlyJsonContractResolver(),
         Converters            = new List <JsonConverter>
         {
             new Iso8601TimeSpanConverter()
         }
     };
     SerializationSettings.Converters.Add(new TransformationJsonConverter());
     DeserializationSettings = new JsonSerializerSettings
     {
         DateFormatHandling    = Newtonsoft.Json.DateFormatHandling.IsoDateFormat,
         DateTimeZoneHandling  = Newtonsoft.Json.DateTimeZoneHandling.Utc,
         NullValueHandling     = Newtonsoft.Json.NullValueHandling.Ignore,
         ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize,
         ContractResolver      = new ReadOnlyJsonContractResolver(),
         Converters            = new List <JsonConverter>
         {
             new Iso8601TimeSpanConverter()
         }
     };
     CustomInitialize();
     DeserializationSettings.Converters.Add(new TransformationJsonConverter());
     DeserializationSettings.Converters.Add(new CloudErrorJsonConverter());
 }
Exemple #12
0
        //设置站点绑定的协议、端口
        private bool SetSiteProtolPort(List <string> AListStrSetting, ref string AStrReturn)
        {
            bool   LBoolReturn               = true;
            string LStrCallReturn            = string.Empty;
            Site   LSiteUMPPF                = null;
            int    LIntHttpBindingPort       = 0;
            int    LintHttpsBindingPort      = 0;
            int    LIntNetTcpBindingPort     = 0;
            string LStrCertificateFile       = string.Empty;
            string LStrCertificateHashString = string.Empty;

            byte[] LByteCertificateHash = null;

            try
            {
                App.GStrCatchException = string.Empty;
                AStrReturn             = "006";
                ServerManager LServerManager = new ServerManager();
                foreach (Site LSiteSingle in LServerManager.Sites)
                {
                    if (LSiteSingle.Name.Equals("UMP.PF"))
                    {
                        LSiteUMPPF = LSiteSingle; AStrReturn = string.Empty; break;
                    }
                }
                if (AStrReturn == "006")
                {
                    return(false);
                }

                App.WriteLog("SetBinding", string.Format("UMPSite getted."));

                LSiteUMPPF.Bindings.Clear();
                LServerManager.CommitChanges();
                LServerManager.Dispose();
                LServerManager = null;

                LBoolReturn = CertificateOperations.UninstallCertificate(AListStrSetting[0], StoreName.My, StoreLocation.CurrentUser, ref LStrCallReturn);
                LBoolReturn = CertificateOperations.UninstallCertificate(AListStrSetting[0], StoreName.My, StoreLocation.LocalMachine, ref LStrCallReturn);
                LBoolReturn = CertificateOperations.UninstallCertificate(AListStrSetting[0], StoreName.Root, StoreLocation.LocalMachine, ref LStrCallReturn);

                LStrCertificateFile = System.IO.Path.Combine(App.GStrSiteRootFolder, @"Components\Certificates", "UMP.S." + AListStrSetting[0] + ".pfx");
                if (File.Exists(LStrCertificateFile))
                {
                    File.Delete(LStrCertificateFile);
                }
                LBoolReturn = CertificateOperations.CreateCertificate(AListStrSetting[0], ref LStrCallReturn);
                if (!LBoolReturn)
                {
                    AStrReturn             = "013"; //在当前用户的 My 区域中创建证书失败
                    App.GStrCatchException = LStrCallReturn;
                    return(LBoolReturn);
                }

                App.WriteLog("SetBinding", string.Format("Server certificate created.\t{0}", LStrCallReturn));

                LStrCertificateHashString = LStrCallReturn;
                IStrBindHashString        = LStrCertificateHashString;
                LBoolReturn = CertificateOperations.ExportCertificate(LStrCertificateHashString, "VoiceCyber,123", LStrCertificateFile, ref LStrCallReturn);
                if (!LBoolReturn)
                {
                    AStrReturn             = "014"; //从当前用户的 My 区域中导出证书失败
                    App.GStrCatchException = LStrCallReturn;
                    return(LBoolReturn);
                }

                App.WriteLog("SetBinding", string.Format("Server certificate exported.\t{0}", LStrCertificateFile));

                LBoolReturn = CertificateOperations.CertificateIsExist(LStrCertificateHashString, StoreName.My, StoreLocation.LocalMachine, ref LStrCallReturn);
                if (!LBoolReturn)
                {
                    if (!string.IsNullOrEmpty(LStrCallReturn))
                    {
                        AStrReturn             = "018"; //检测本计算机的 My 区域中是否安装证书失败
                        App.GStrCatchException = LStrCallReturn;
                        return(LBoolReturn);
                    }
                    LBoolReturn = CertificateOperations.InstallCertificate(LStrCertificateFile, "VoiceCyber,123", StoreName.My, StoreLocation.LocalMachine, ref LStrCallReturn);
                    if (!LBoolReturn)
                    {
                        AStrReturn             = "015"; //向本计算机的 My 区域中安装证书失败
                        App.GStrCatchException = LStrCallReturn;
                        return(LBoolReturn);
                    }

                    App.WriteLog("SetBinding", string.Format("Install server certificate end.\t{0}", "My"));
                }

                LByteCertificateHash = CertificateOperations.ObtainCertificateCertHash(LStrCertificateHashString, StoreName.My, StoreLocation.LocalMachine, ref LStrCallReturn);
                if (LByteCertificateHash == null)
                {
                    LBoolReturn            = false;
                    AStrReturn             = "016"; //从本计算机的 My 区域中获取证书的哈希值数组失败
                    App.GStrCatchException = LStrCallReturn;
                    return(LBoolReturn);
                }

                App.WriteLog("SetBinding", string.Format("ObtainCertificateCertHash end."));

                LBoolReturn = CertificateOperations.CertificateIsExist(LStrCertificateHashString, StoreName.Root, StoreLocation.LocalMachine, ref LStrCallReturn);
                if (!LBoolReturn)
                {
                    if (!string.IsNullOrEmpty(LStrCallReturn))
                    {
                        AStrReturn             = "019"; //检测本计算机的 Root 区域中是否安装证书失败
                        App.GStrCatchException = LStrCallReturn;
                        return(LBoolReturn);
                    }
                    LBoolReturn = CertificateOperations.InstallCertificate(LStrCertificateFile, "VoiceCyber,123", StoreName.Root, StoreLocation.LocalMachine, ref LStrCallReturn);
                    if (!LBoolReturn)
                    {
                        AStrReturn             = "017"; //向本计算机的 Root 区域中安装证书失败
                        App.GStrCatchException = LStrCallReturn;
                        return(LBoolReturn);
                    }

                    App.WriteLog("SetBinding", string.Format("Install server certificate end.\t{0}", "Root"));
                }

                LServerManager = new ServerManager();
                foreach (Site LSiteSingle in LServerManager.Sites)
                {
                    if (LSiteSingle.Name.Equals("UMP.PF"))
                    {
                        LSiteUMPPF = LSiteSingle; AStrReturn = string.Empty; break;
                    }
                }
                LIntHttpBindingPort  = int.Parse(AListStrSetting[1]);
                LintHttpsBindingPort = LIntHttpBindingPort + 1;

                LSiteUMPPF.Bindings.Add("*:" + AListStrSetting[1] + ":", "http");
                LSiteUMPPF.Bindings.Add("*:" + LintHttpsBindingPort.ToString() + ":", LByteCertificateHash, "MY");
                LSiteUMPPF.Bindings.Add(AListStrSetting[2] + ":*", "net.tcp");

                App.WriteLog("SetBinding", string.Format("Add binding end."));

                //LSiteUMPPF.ApplicationDefaults.EnabledProtocols
                var app = LSiteUMPPF.Applications["/WCF1600"];
                if (app != null)
                {
                    app.EnabledProtocols = "http,net.tcp";

                    App.WriteLog("SetBinding", string.Format("Set protocol for WCF1600 end."));
                }
                LServerManager.CommitChanges();
                LServerManager.Dispose();
                LServerManager = null;
            }
            catch (Exception ex)
            {
                LBoolReturn            = false;
                AStrReturn             = "010";
                App.GStrCatchException = "SetSiteProtolPort()" + ex.ToString();
            }

            return(LBoolReturn);
        }