Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ CreateFromPem() [1/2]

static X509Certificate2 System.Security.Cryptography.X509Certificates.X509Certificate2.CreateFromPem ( ReadOnlySpan< char > certPem)
inlinestatic

Definition at line 729 of file X509Certificate2.cs.

730 {
732 while (enumerator.MoveNext())
733 {
735 ReadOnlySpan<char> readOnlySpan = contents;
736 PemFields pemFields2 = pemFields;
737 contents = readOnlySpan;
738 ReadOnlySpan<char> span = contents[pemFields2.Label];
739 if (span.SequenceEqual("CERTIFICATE"))
740 {
741 byte[] array = System.Security.Cryptography.CryptoPool.Rent(pemFields2.DecodedDataLength);
742 contents = readOnlySpan;
743 if (!Convert.TryFromBase64Chars(contents[pemFields2.Base64Data], array, out var bytesWritten) || bytesWritten != pemFields2.DecodedDataLength)
744 {
745 throw new CryptographicException(System.SR.Cryptography_X509_NoPemCertificate);
746 }
747 ReadOnlyMemory<byte> encoded = new ReadOnlyMemory<byte>(array, 0, bytesWritten);
748 try
749 {
751 }
752 catch (CryptographicException)
753 {
754 throw new CryptographicException(System.SR.Cryptography_X509_NoPemCertificate);
755 }
756 X509Certificate2 result = new X509Certificate2(encoded.Span);
758 return result;
759 }
760 }
761 throw new CryptographicException(System.SR.Cryptography_X509_NoPemCertificate);
762 }
static string Cryptography_X509_NoPemCertificate
Definition SR.cs:104
Definition SR.cs:7
static void Return(byte[] array, int clearSize=-1)
Definition CryptoPool.cs:12
static byte[] Rent(int minimumLength)
Definition CryptoPool.cs:7
void Deconstruct(out ReadOnlySpan< char > contents, out PemFields pemFields)
static CertificateAsn Decode(ReadOnlyMemory< byte > encoded, AsnEncodingRules ruleSet)

References System.Security.Cryptography.X509Certificates.X509Certificate2.X509Certificate2(), System.array, System.SR.Cryptography_X509_NoPemCertificate, Internal.Cryptography.PemEnumerator.Enumerator.Current, System.Security.Cryptography.X509Certificates.Asn1.CertificateAsn.Decode(), Internal.Cryptography.PemEnumerator.Enumerator.PemFieldItem.Deconstruct(), System.Runtime.Serialization.Dictionary, Internal.Cryptography.PemEnumerator.GetEnumerator(), System.Security.Cryptography.CryptoPool.Rent(), System.Security.Cryptography.CryptoPool.Return(), and System.Convert.TryFromBase64Chars().