本文整理匯總了C#中System.Security.Cryptography.X509Certificates.X509Store.GetHashCode方法的典型用法代碼示例。如果您正苦於以下問題:C# X509Store.GetHashCode方法的具體用法?C# X509Store.GetHashCode怎麽用?C# X509Store.GetHashCode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Security.Cryptography.X509Certificates.X509Store
的用法示例。
在下文中一共展示了X509Store.GetHashCode方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: EnsureStoreOpened
internal static X509Store EnsureStoreOpened(bool isMachineStore)
{
X509Store store = isMachineStore? s_MyMachineCertStoreEx: s_MyCertStoreEx;
if (store == null) {
lock (s_SyncObject) {
store = isMachineStore? s_MyMachineCertStoreEx: s_MyCertStoreEx;
if (store==null) {
// NOTE: that if this call fails we won't keep track and the next time we enter we will try to open the store again
StoreLocation storeLocation = isMachineStore? StoreLocation.LocalMachine: StoreLocation.CurrentUser;
store = new X509Store(StoreName.My, storeLocation);
try {
//
// For v 1.1 compat We want to ensure the store is opened under the **process** acount.
//
try {
#if FEATURE_MONO_CAS
using (WindowsIdentity.Impersonate(IntPtr.Zero))
#endif
{
store.Open(OpenFlags.ReadOnly | OpenFlags.OpenExistingOnly);
GlobalLog.Print("SecureChannel::EnsureStoreOpened() storeLocation:" + storeLocation + " returned store:" + store.GetHashCode().ToString("x"));
}
} catch {
throw;
}
if (isMachineStore)
s_MyMachineCertStoreEx = store;
else
s_MyCertStoreEx = store;
return store;
}
catch (Exception exception) {
if (exception is CryptographicException || exception is SecurityException) {
GlobalLog.Assert("SecureChannel::EnsureStoreOpened()", "Failed to open cert store, location:" + storeLocation + " exception:" + exception);
return null;
}
if (Logging.On) Logging.PrintError(Logging.Web, SR.GetString(SR.net_log_open_store_failed, storeLocation, exception));
throw;
}
}
}
}
return store;
}
示例2: EnsureStoreOpened
//
// Security: We temporarily reset thread token to open the cert store under process account.
//
internal static X509Store EnsureStoreOpened(bool isMachineStore)
{
X509Store store = isMachineStore ? s_myMachineCertStoreEx : s_myCertStoreEx;
// TODO #3862 Investigate if this can be switched to either the static or Lazy<T> patterns.
if (store == null)
{
lock (s_syncObject)
{
store = isMachineStore ? s_myMachineCertStoreEx : s_myCertStoreEx;
if (store == null)
{
// NOTE: that if this call fails we won't keep track and the next time we enter we will try to open the store again.
StoreLocation storeLocation = isMachineStore ? StoreLocation.LocalMachine : StoreLocation.CurrentUser;
store = new X509Store(StoreName.My, storeLocation);
try
{
// For app-compat We want to ensure the store is opened under the **process** account.
try
{
WindowsIdentity.RunImpersonated(SafeAccessTokenHandle.InvalidHandle, () =>
{
store.Open(OpenFlags.ReadOnly | OpenFlags.OpenExistingOnly);
if (GlobalLog.IsEnabled)
{
GlobalLog.Print("SecureChannel::EnsureStoreOpened() storeLocation:" + storeLocation + " returned store:" + store.GetHashCode().ToString("x"));
}
});
}
catch
{
throw;
}
if (isMachineStore)
{
s_myMachineCertStoreEx = store;
}
else
{
s_myCertStoreEx = store;
}
return store;
}
catch (Exception exception)
{
if (exception is CryptographicException || exception is SecurityException)
{
if (GlobalLog.IsEnabled)
{
GlobalLog.Assert("SecureChannel::EnsureStoreOpened()", "Failed to open cert store, location:" + storeLocation + " exception:" + exception);
}
Debug.Fail("SecureChannel::EnsureStoreOpened()", "Failed to open cert store, location:" + storeLocation + " exception:" + exception);
return null;
}
if (NetEventSource.Log.IsEnabled())
{
NetEventSource.PrintError(NetEventSource.ComponentType.Security, SR.Format(SR.net_log_open_store_failed, storeLocation, exception));
}
throw;
}
}
}
}
return store;
}
示例3: EnsureStoreOpened
private static X509Store EnsureStoreOpened(ref X509Store storeField, StoreLocation storeLocation)
{
X509Store store = Volatile.Read(ref storeField);
if (store == null)
{
lock (s_lockObject)
{
store = Volatile.Read(ref storeField);
if (store == null)
{
try
{
store = new X509Store(StoreName.My, storeLocation);
store.Open(OpenFlags.ReadOnly);
Volatile.Write(ref storeField, store);
if (GlobalLog.IsEnabled)
{
GlobalLog.Print(
"CertModule::EnsureStoreOpened() storeLocation:" + storeLocation +
" returned store:" + store.GetHashCode().ToString("x"));
}
}
catch (CryptographicException e)
{
if (GlobalLog.IsEnabled)
{
GlobalLog.Assert(
"CertModule::EnsureStoreOpened()",
"Failed to open cert store, location:" + storeLocation + " exception:" + e);
}
Debug.Fail(
"CertModule::EnsureStoreOpened()",
"Failed to open cert store, location:" + storeLocation + " exception:" + e);
throw;
}
}
}
}
return store;
}