本文整理汇总了C#中System.Security.Cryptography.OidCollection类的典型用法代码示例。如果您正苦于以下问题:C# OidCollection类的具体用法?C# OidCollection怎么用?C# OidCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OidCollection类属于System.Security.Cryptography命名空间,在下文中一共展示了OidCollection类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: CopyToOidNull
public void CopyToOidNull ()
{
OidCollection oc = new OidCollection ();
oc.Add (new Oid ("1.0"));
Oid[] array = null;
oc.CopyTo (array, 0);
}
开发者ID:nlhepler,项目名称:mono,代码行数:7,代码来源:OidCollectionTest.cs
示例2: BuildChain
internal static unsafe int BuildChain(IntPtr hChainEngine, System.Security.Cryptography.SafeCertContextHandle pCertContext, X509Certificate2Collection extraStore, OidCollection applicationPolicy, OidCollection certificatePolicy, X509RevocationMode revocationMode, X509RevocationFlag revocationFlag, DateTime verificationTime, TimeSpan timeout, ref SafeCertChainHandle ppChainContext)
{
if (pCertContext == null || pCertContext.IsInvalid)
throw new ArgumentException(SecurityResources.GetResourceString("Cryptography_InvalidContextHandle"), "pCertContext");
SafeCertStoreHandle hAdditionalStore = SafeCertStoreHandle.InvalidHandle;
if (extraStore != null && extraStore.Count > 0)
hAdditionalStore = X509Utils.ExportToMemoryStore(extraStore);
CAPI.CERT_CHAIN_PARA pChainPara = new CAPI.CERT_CHAIN_PARA();
pChainPara.cbSize = (uint)Marshal.SizeOf((object)pChainPara);
SafeLocalAllocHandle localAllocHandle1 = SafeLocalAllocHandle.InvalidHandle;
if (applicationPolicy != null && applicationPolicy.Count > 0)
{
pChainPara.RequestedUsage.dwType = 0U;
pChainPara.RequestedUsage.Usage.cUsageIdentifier = (uint)applicationPolicy.Count;
localAllocHandle1 = X509Utils.CopyOidsToUnmanagedMemory(applicationPolicy);
pChainPara.RequestedUsage.Usage.rgpszUsageIdentifier = localAllocHandle1.DangerousGetHandle();
}
SafeLocalAllocHandle localAllocHandle2 = SafeLocalAllocHandle.InvalidHandle;
if (certificatePolicy != null && certificatePolicy.Count > 0)
{
pChainPara.RequestedIssuancePolicy.dwType = 0U;
pChainPara.RequestedIssuancePolicy.Usage.cUsageIdentifier = (uint)certificatePolicy.Count;
localAllocHandle2 = X509Utils.CopyOidsToUnmanagedMemory(certificatePolicy);
pChainPara.RequestedIssuancePolicy.Usage.rgpszUsageIdentifier = localAllocHandle2.DangerousGetHandle();
}
pChainPara.dwUrlRetrievalTimeout = (uint)timeout.Milliseconds;
System.Runtime.InteropServices.ComTypes.FILETIME pTime = new System.Runtime.InteropServices.ComTypes.FILETIME();
*(long*)&pTime = verificationTime.ToFileTime();
uint dwFlags = X509Utils.MapRevocationFlags(revocationMode, revocationFlag);
if (!CAPI.CAPISafe.CertGetCertificateChain(hChainEngine, pCertContext, ref pTime, hAdditionalStore, ref pChainPara, dwFlags, IntPtr.Zero, out ppChainContext))
return Marshal.GetHRForLastWin32Error();
localAllocHandle1.Dispose();
localAllocHandle2.Dispose();
return 0;
}
开发者ID:scholtz,项目名称:FastZep,代码行数:35,代码来源:X509Utils.cs
示例3: AddNull
//BUG [ExpectedException (typeof (ArgumentNullException))]
public void AddNull ()
{
OidCollection oc = new OidCollection ();
oc.Add (null);
Assert.AreEqual (1, oc.Count, "Count");
// Assert.IsNull (oc, "[0]"); throw NullReferenceException
}
开发者ID:nlhepler,项目名称:mono,代码行数:8,代码来源:OidCollectionTest.cs
示例4: AddNull
//BUG [ExpectedException (typeof (ArgumentNullException))]
public void AddNull ()
{
OidCollection oc = new OidCollection ();
oc.Add (null);
AssertEquals ("Count", 1, oc.Count);
// AssertNull ("[0]", oc); throw NullReferenceException
}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:8,代码来源:OidCollectionTest.cs
示例5: Add
public void Add ()
{
OidCollection oc = new OidCollection ();
oc.Add (new Oid ("1.0"));
Assert.AreEqual (1, oc.Count, "Count");
Assert.AreEqual ("1.0", oc [0].Value, "[0]");
Assert.AreEqual ("1.0", oc ["1.0"].Value, "['1.0']");
}
开发者ID:nlhepler,项目名称:mono,代码行数:8,代码来源:OidCollectionTest.cs
示例6: GetEnumerator
private OidEnumerator GetEnumerator ()
{
OidCollection oc = new OidCollection ();
oc.Add (new Oid ("1.0"));
oc.Add (new Oid ("1.1"));
oc.Add (new Oid ("1.2"));
return oc.GetEnumerator ();
}
开发者ID:nlhepler,项目名称:mono,代码行数:8,代码来源:OidEnumeratorTest.cs
示例7: Add
public void Add ()
{
OidCollection oc = new OidCollection ();
oc.Add (new Oid ("1.0"));
AssertEquals ("Count", 1, oc.Count);
AssertEquals ("[0]", "1.0", oc [0].Value);
AssertEquals ("['1.0']", "1.0", oc ["1.0"].Value);
}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:8,代码来源:OidCollectionTest.cs
示例8: CopyToOid
public void CopyToOid ()
{
OidCollection oc = new OidCollection ();
oc.Add (new Oid ("1.0"));
Oid[] array = new Oid [1];
oc.CopyTo (array, 0);
Assert.AreEqual ("1.0", array [0].Value, "CopyTo(Oid)");
}
开发者ID:nlhepler,项目名称:mono,代码行数:8,代码来源:OidCollectionTest.cs
示例9: Constructor
public void Constructor ()
{
OidCollection oc = new OidCollection ();
// default properties
Assert.AreEqual (0, oc.Count, "Count");
Assert.IsTrue (!oc.IsSynchronized, "IsSynchronized");
Assert.IsNotNull (oc.SyncRoot, "SyncRoot");
Assert.IsNotNull (oc.GetEnumerator (), "GetEnumerator");
}
开发者ID:nlhepler,项目名称:mono,代码行数:9,代码来源:OidCollectionTest.cs
示例10: BuildChain
public static IChainPal BuildChain(
bool useMachineContext,
ICertificatePal cert,
X509Certificate2Collection extraStore,
OidCollection applicationPolicy,
OidCollection certificatePolicy,
X509RevocationMode revocationMode,
X509RevocationFlag revocationFlag,
DateTime verificationTime,
TimeSpan timeout)
{
// An input value of 0 on the timeout is "take all the time you need".
if (timeout == TimeSpan.Zero)
{
timeout = TimeSpan.MaxValue;
}
// Let Unspecified mean Local, so only convert if the source was UTC.
//
// Converge on Local instead of UTC because OpenSSL is going to assume we gave it
// local time.
if (verificationTime.Kind == DateTimeKind.Utc)
{
verificationTime = verificationTime.ToLocalTime();
}
TimeSpan remainingDownloadTime = timeout;
var leaf = new X509Certificate2(cert.Handle);
var downloaded = new HashSet<X509Certificate2>();
var systemTrusted = new HashSet<X509Certificate2>();
HashSet<X509Certificate2> candidates = OpenSslX509ChainProcessor.FindCandidates(
leaf,
extraStore,
downloaded,
systemTrusted,
ref remainingDownloadTime);
IChainPal chain = OpenSslX509ChainProcessor.BuildChain(
leaf,
candidates,
downloaded,
systemTrusted,
applicationPolicy,
certificatePolicy,
revocationMode,
revocationFlag,
verificationTime,
ref remainingDownloadTime);
if (chain.ChainStatus.Length == 0 && downloaded.Count > 0)
{
SaveIntermediateCertificates(chain.ChainElements, downloaded);
}
return chain;
}
开发者ID:SGuyGe,项目名称:corefx,代码行数:57,代码来源:ChainPal.cs
示例11: Constructor
public void Constructor ()
{
OidCollection oc = new OidCollection ();
// default properties
AssertEquals ("Count", 0, oc.Count);
Assert ("IsSynchronized", !oc.IsSynchronized);
AssertNotNull ("SyncRoot", oc.SyncRoot);
AssertNotNull ("GetEnumerator", oc.GetEnumerator ());
}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:9,代码来源:OidCollectionTest.cs
示例12: BuildChain
/// <summary>
/// Does not throw on error. Returns null ChainPal instead.
/// </summary>
public static ChainPal BuildChain(
bool useMachineContext,
ICertificatePal cert,
X509Certificate2Collection extraStore,
OidCollection applicationPolicy,
OidCollection certificatePolicy,
X509RevocationMode revocationMode,
X509RevocationFlag revocationFlag,
DateTime verificationTime,
TimeSpan timeout)
{
CertificatePal certificatePal = (CertificatePal)cert;
unsafe
{
using (SafeCertStoreHandle extraStoreHandle = ConvertExtraStoreToSafeHandle(extraStore))
{
CERT_CHAIN_PARA chainPara = new CERT_CHAIN_PARA();
chainPara.cbSize = Marshal.SizeOf<CERT_CHAIN_PARA>();
int applicationPolicyCount;
using (SafeHandle applicationPolicyOids = applicationPolicy.ToLpstrArray(out applicationPolicyCount))
{
if (!applicationPolicyOids.IsInvalid)
{
chainPara.RequestedUsage.dwType = CertUsageMatchType.USAGE_MATCH_TYPE_AND;
chainPara.RequestedUsage.Usage.cUsageIdentifier = applicationPolicyCount;
chainPara.RequestedUsage.Usage.rgpszUsageIdentifier = applicationPolicyOids.DangerousGetHandle();
}
int certificatePolicyCount;
using (SafeHandle certificatePolicyOids = certificatePolicy.ToLpstrArray(out certificatePolicyCount))
{
if (!certificatePolicyOids.IsInvalid)
{
chainPara.RequestedIssuancePolicy.dwType = CertUsageMatchType.USAGE_MATCH_TYPE_AND;
chainPara.RequestedIssuancePolicy.Usage.cUsageIdentifier = certificatePolicyCount;
chainPara.RequestedIssuancePolicy.Usage.rgpszUsageIdentifier = certificatePolicyOids.DangerousGetHandle();
}
chainPara.dwUrlRetrievalTimeout = (int)Math.Floor(timeout.TotalMilliseconds);
FILETIME ft = FILETIME.FromDateTime(verificationTime);
CertChainFlags flags = MapRevocationFlags(revocationMode, revocationFlag);
ChainEngine chainEngine = useMachineContext ? ChainEngine.HCCE_LOCAL_MACHINE : ChainEngine.HCCE_CURRENT_USER;
SafeX509ChainHandle chain;
if (!Interop.crypt32.CertGetCertificateChain(chainEngine, certificatePal.CertContext, &ft, extraStoreHandle, ref chainPara, flags, IntPtr.Zero, out chain))
return null;
return new ChainPal(chain);
}
}
}
}
}
开发者ID:ChuangYang,项目名称:corefx,代码行数:58,代码来源:ChainPal.BuildChain.cs
示例13: Reset
public void Reset()
{
this.m_applicationPolicy = new OidCollection();
this.m_certificatePolicy = new OidCollection();
this.m_revocationMode = X509RevocationMode.Online;
this.m_revocationFlag = X509RevocationFlag.ExcludeRoot;
this.m_verificationFlags = X509VerificationFlags.NoFlag;
this.m_verificationTime = DateTime.Now;
this.m_timeout = new TimeSpan(0, 0, 0);
this.m_extraStore = new X509Certificate2Collection();
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:11,代码来源:X509ChainPolicy.cs
示例14: MatchesCertificatePolicies
internal bool MatchesCertificatePolicies(OidCollection policyOids)
{
foreach (Oid oid in policyOids)
{
if (!MatchesCertificatePolicies(oid))
{
return false;
}
}
return true;
}
开发者ID:noahfalk,项目名称:corefx,代码行数:12,代码来源:CertificatePolicy.cs
示例15: BuildChain
public static IChainPal BuildChain(
bool useMachineContext,
ICertificatePal cert,
X509Certificate2Collection extraStore,
OidCollection applicationPolicy,
OidCollection certificatePolicy,
X509RevocationMode revocationMode,
X509RevocationFlag revocationFlag,
DateTime verificationTime,
TimeSpan timeout)
{
return new OpenSslX509ChainProcessor();
}
开发者ID:johnhhm,项目名称:corefx,代码行数:13,代码来源:ChainPal.cs
示例16: BuildChain
private static unsafe void BuildChain(IntPtr hChainEngine, IntPtr pCertContext, X509Certificate2Collection extraStore, OidCollection applicationPolicy, OidCollection certificatePolicy, X509RevocationMode revocationMode, X509RevocationFlag revocationFlag, DateTime verificationTime, TimeSpan timeout, out System.IdentityModel.SafeCertChainHandle ppChainContext)
{
System.IdentityModel.SafeCertStoreHandle hAdditionalStore = ExportToMemoryStore(extraStore, pCertContext);
System.IdentityModel.CAPI.CERT_CHAIN_PARA pChainPara = new System.IdentityModel.CAPI.CERT_CHAIN_PARA {
cbSize = (uint) Marshal.SizeOf(typeof(System.IdentityModel.CAPI.CERT_CHAIN_PARA))
};
SafeHGlobalHandle invalidHandle = SafeHGlobalHandle.InvalidHandle;
SafeHGlobalHandle handle3 = SafeHGlobalHandle.InvalidHandle;
try
{
if ((applicationPolicy != null) && (applicationPolicy.Count > 0))
{
pChainPara.RequestedUsage.dwType = 0;
pChainPara.RequestedUsage.Usage.cUsageIdentifier = (uint) applicationPolicy.Count;
invalidHandle = CopyOidsToUnmanagedMemory(applicationPolicy);
pChainPara.RequestedUsage.Usage.rgpszUsageIdentifier = invalidHandle.DangerousGetHandle();
}
if ((certificatePolicy != null) && (certificatePolicy.Count > 0))
{
pChainPara.RequestedIssuancePolicy.dwType = 0;
pChainPara.RequestedIssuancePolicy.Usage.cUsageIdentifier = (uint) certificatePolicy.Count;
handle3 = CopyOidsToUnmanagedMemory(certificatePolicy);
pChainPara.RequestedIssuancePolicy.Usage.rgpszUsageIdentifier = handle3.DangerousGetHandle();
}
pChainPara.dwUrlRetrievalTimeout = (uint) timeout.Milliseconds;
System.Runtime.InteropServices.ComTypes.FILETIME pTime = new System.Runtime.InteropServices.ComTypes.FILETIME();
*((long*) &pTime) = verificationTime.ToFileTime();
uint dwFlags = MapRevocationFlags(revocationMode, revocationFlag);
if (!System.IdentityModel.CAPI.CertGetCertificateChain(hChainEngine, pCertContext, ref pTime, hAdditionalStore, ref pChainPara, dwFlags, IntPtr.Zero, out ppChainContext))
{
int hr = Marshal.GetLastWin32Error();
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new CryptographicException(hr));
}
}
finally
{
if (invalidHandle != null)
{
invalidHandle.Dispose();
}
if (handle3 != null)
{
handle3.Dispose();
}
hAdditionalStore.Close();
}
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:47,代码来源:X509CertificateChain.cs
示例17: BuildChain
public static IChainPal BuildChain(
bool useMachineContext,
ICertificatePal cert,
X509Certificate2Collection extraStore,
OidCollection applicationPolicy,
OidCollection certificatePolicy,
X509RevocationMode revocationMode,
X509RevocationFlag revocationFlag,
DateTime verificationTime,
TimeSpan timeout)
{
CheckRevocationMode(revocationMode);
// An input value of 0 on the timeout is "take all the time you need".
if (timeout == TimeSpan.Zero)
{
timeout = TimeSpan.MaxValue;
}
TimeSpan remainingDownloadTime = timeout;
X509Certificate2 leaf = new X509Certificate2(cert.Handle);
List<X509Certificate2> downloaded = new List<X509Certificate2>();
List<X509Certificate2> candidates = OpenSslX509ChainProcessor.FindCandidates(
leaf,
extraStore,
downloaded,
ref remainingDownloadTime);
IChainPal chain = OpenSslX509ChainProcessor.BuildChain(
leaf,
candidates,
downloaded,
applicationPolicy,
certificatePolicy,
verificationTime);
if (chain.ChainStatus.Length == 0 && downloaded.Count > 0)
{
SaveIntermediateCertificates(chain.ChainElements, downloaded);
}
return chain;
}
开发者ID:nelsonsar,项目名称:corefx,代码行数:44,代码来源:ChainPal.cs
示例18: CreateSelfSignedCert
/// <summary>
/// Creates a new self-signed X509 certificate
/// </summary>
/// <param name="issuer">The certificate issuer</param>
/// <param name="friendlyName">Human readable name</param>
/// <param name="password">The certificate's password</param>
/// <param name="startTime">Certificate creation date & time</param>
/// <param name="endTime">Certificate expiry date & time</param>
/// <returns>An X509Certificate2</returns>
public static X509Certificate2 CreateSelfSignedCert(string issuer, string friendlyName, string password, DateTime startTime, DateTime endTime)
{
string distinguishedNameString = issuer;
var key = Create2048RsaKey();
var creationParams = new X509CertificateCreationParameters(new X500DistinguishedName(distinguishedNameString))
{
TakeOwnershipOfKey = true,
StartTime = startTime,
EndTime = endTime
};
// adding client authentication, -eku = 1.3.6.1.5.5.7.3.2,
// This is mandatory for the upload to be successful
OidCollection oidCollection = new OidCollection();
oidCollection.Add(new Oid(OIDClientAuthValue, OIDClientAuthFriendlyName));
creationParams.Extensions.Add(new X509EnhancedKeyUsageExtension(oidCollection, false));
// Documentation of CreateSelfSignedCertificate states:
// If creationParameters have TakeOwnershipOfKey set to true, the certificate
// generated will own the key and the input CngKey will be disposed to ensure
// that the caller doesn't accidentally use it beyond its lifetime (which is
// now controlled by the certificate object).
// We don't dispose it ourselves in this case.
var cert = key.CreateSelfSignedCertificate(creationParams);
key = null;
cert.FriendlyName = friendlyName;
// X509 certificate needs PersistKeySet flag set.
// Reload a new X509Certificate2 instance from exported bytes in order to set the PersistKeySet flag.
var bytes = cert.Export(X509ContentType.Pfx, password);
// NOTE: PfxValidation is not done here because these are newly created certs and assumed valid.
ICommonEventSource evtSource = null;
return X509Certificate2Helper.NewX509Certificate2(bytes, password, X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.Exportable, evtSource, doPfxValidation: false);
}
开发者ID:FrankSiegemund,项目名称:azure-powershell,代码行数:46,代码来源:CertUtils.cs
示例19: X509EnhancedKeyUsageExtension
public X509EnhancedKeyUsageExtension() : base (CAPI.szOID_ENHANCED_KEY_USAGE) {
m_enhancedKeyUsages = new OidCollection();
m_decoded = true;
}
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:4,代码来源:X509Extension.cs
示例20: DecodeX509EnhancedKeyUsageExtension
public void DecodeX509EnhancedKeyUsageExtension(byte[] encoded, out OidCollection usages)
{
OidCollection localUsages = new OidCollection();
unsafe
{
encoded.DecodeObject(
CryptDecodeObjectStructType.X509_ENHANCED_KEY_USAGE,
delegate (void* pvDecoded)
{
CERT_ENHKEY_USAGE* pEnhKeyUsage = (CERT_ENHKEY_USAGE*)pvDecoded;
int count = pEnhKeyUsage->cUsageIdentifier;
for (int i = 0; i < count; i++)
{
IntPtr oidValuePointer = pEnhKeyUsage->rgpszUsageIdentifier[i];
string oidValue = Marshal.PtrToStringAnsi(oidValuePointer);
Oid oid = new Oid(oidValue);
localUsages.Add(oid);
}
}
);
}
usages = localUsages;
}
开发者ID:er0dr1guez,项目名称:corefx,代码行数:25,代码来源:X509Pal.CustomExtensions.cs
注:本文中的System.Security.Cryptography.OidCollection类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论