本文整理汇总了C#中Microsoft.Win32.SafeHandles.SafeBioHandle类的典型用法代码示例。如果您正苦于以下问题:C# SafeBioHandle类的具体用法?C# SafeBioHandle怎么用?C# SafeBioHandle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SafeBioHandle类属于Microsoft.Win32.SafeHandles命名空间,在下文中一共展示了SafeBioHandle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsPkcs7Pem
internal static bool IsPkcs7Pem(SafeBioHandle fileBio)
{
using (SafePkcs7Handle pkcs7 = Interop.Crypto.PemReadBioPkcs7(fileBio))
{
return !pkcs7.IsInvalid;
}
}
示例2: IsPkcs7Der
internal static bool IsPkcs7Der(SafeBioHandle fileBio)
{
using (SafePkcs7Handle pkcs7 = Interop.Crypto.D2IPkcs7Bio(fileBio))
{
return !pkcs7.IsInvalid;
}
}
示例3: FromBio
private static IStorePal FromBio(SafeBioHandle bio, string password)
{
int bioPosition = Interop.Crypto.BioTell(bio);
Debug.Assert(bioPosition >= 0);
ICertificatePal singleCert;
if (CertificatePal.TryReadX509Pem(bio, out singleCert))
{
return SingleCertToStorePal(singleCert);
}
// Rewind, try again.
CertificatePal.RewindBio(bio, bioPosition);
if (CertificatePal.TryReadX509Der(bio, out singleCert))
{
return SingleCertToStorePal(singleCert);
}
// Rewind, try again.
CertificatePal.RewindBio(bio, bioPosition);
List<ICertificatePal> certPals;
if (PkcsFormatReader.TryReadPkcs7Pem(bio, out certPals))
{
return ListToStorePal(certPals);
}
// Rewind, try again.
CertificatePal.RewindBio(bio, bioPosition);
if (PkcsFormatReader.TryReadPkcs7Der(bio, out certPals))
{
return ListToStorePal(certPals);
}
// Rewind, try again.
CertificatePal.RewindBio(bio, bioPosition);
if (PkcsFormatReader.TryReadPkcs12(bio, password, out certPals))
{
return ListToStorePal(certPals);
}
// Since we aren't going to finish reading, leaving the buffer where it was when we got
// it seems better than leaving it in some arbitrary other position.
//
// But, before seeking back to start, save the Exception representing the last reported
// OpenSSL error in case the last BioSeek would change it.
Exception openSslException = Interop.Crypto.CreateOpenSslCryptographicException();
// Use BioSeek directly for the last seek attempt, because any failure here should instead
// report the already created (but not yet thrown) exception.
Interop.Crypto.BioSeek(bio, bioPosition);
throw openSslException;
}
示例4: RewindBio
internal static void RewindBio(SafeBioHandle bio, int bioPosition)
{
int ret = Interop.Crypto.BioSeek(bio, bioPosition);
if (ret < 0)
{
throw Interop.Crypto.CreateOpenSslCryptographicException();
}
}
示例5: TryRead
public static bool TryRead(SafeBioHandle fileBio, out OpenSslPkcs12Reader pkcs12Reader)
{
SafePkcs12Handle p12 = Interop.Crypto.DecodePkcs12FromBio(fileBio);
if (!p12.IsInvalid)
{
pkcs12Reader = new OpenSslPkcs12Reader(p12);
return true;
}
pkcs12Reader = null;
return false;
}
示例6: TryRead
public static bool TryRead(SafeBioHandle fileBio, out OpenSslPkcs12Reader pkcs12Reader)
{
SafePkcs12Handle p12 = Interop.libcrypto.d2i_PKCS12_bio(fileBio, IntPtr.Zero);
if (!p12.IsInvalid)
{
pkcs12Reader = new OpenSslPkcs12Reader(p12);
return true;
}
pkcs12Reader = null;
return false;
}
示例7: TryReadPkcs7Der
private static bool TryReadPkcs7Der(
SafeBioHandle bio,
bool single,
out ICertificatePal certPal,
out List<ICertificatePal> certPals)
{
using (SafePkcs7Handle pkcs7 = Interop.Crypto.D2IPkcs7Bio(bio))
{
if (pkcs7.IsInvalid)
{
certPal = null;
certPals = null;
return false;
}
return TryReadPkcs7(pkcs7, single, out certPal, out certPals);
}
}
示例8: TryReadPkcs7Der
private static bool TryReadPkcs7Der(
SafeBioHandle bio,
bool single,
out ICertificatePal certPal,
out List<ICertificatePal> certPals)
{
SafePkcs7Handle pkcs7 = Interop.libcrypto.d2i_PKCS7_bio(bio, IntPtr.Zero);
if (pkcs7.IsInvalid)
{
certPal = null;
certPals = null;
return false;
}
using (pkcs7)
{
return TryReadPkcs7(pkcs7, single, out certPal, out certPals);
}
}
示例9: TryReadPkcs12
internal static bool TryReadPkcs12(SafeBioHandle bio, string password, out ICertificatePal certPal)
{
List<ICertificatePal> ignored;
return TryReadPkcs12(bio, password, true, out certPal, out ignored);
}
示例10: BioWrite
internal static unsafe extern int BioWrite(SafeBioHandle b, byte* data, int len);
示例11: PEM_read_bio_X509_AUX
internal static extern SafeX509Handle PEM_read_bio_X509_AUX(SafeBioHandle bio, IntPtr zero, IntPtr zero1, IntPtr zero2);
示例12: BioRead
private static int BioRead(SafeBioHandle bio, byte[] buffer, int count)
{
Debug.Assert(buffer != null);
Debug.Assert(count >= 0);
Debug.Assert(buffer.Length >= count);
int bytes = Crypto.BioRead(bio, buffer, count);
if (bytes != count)
{
throw CreateSslException(SR.net_ssl_read_bio_failed_error);
}
return bytes;
}
示例13: TryReadX509Pem
internal static bool TryReadX509Pem(SafeBioHandle bio, out ICertificatePal certPal)
{
SafeX509Handle cert = Interop.Crypto.PemReadX509FromBio(bio);
if (cert.IsInvalid)
{
cert.Dispose();
certPal = null;
return false;
}
certPal = new OpenSslX509CertificateReader(cert);
return true;
}
示例14: TryReadPkcs7Pem
internal static bool TryReadPkcs7Pem(SafeBioHandle bio, out List<ICertificatePal> certPals)
{
ICertificatePal ignored;
return TryReadPkcs7Pem(bio, false, out ignored, out certPals);
}
示例15: PemWriteBioX509Crl
internal static extern int PemWriteBioX509Crl(SafeBioHandle bio, SafeX509CrlHandle crl);