X509Certificate.Export 메서드

정의

현재 X509Certificate 개체를 바이트 배열로 내보냅니다.

오버로드

Name Description
Export(X509ContentType)

값 중 하나에서 설명하는 형식으로 현재 X509Certificate 개체를 바이트 배열로 내보 X509ContentType 냅니다.

Export(X509ContentType, SecureString)

지정된 형식과 암호를 사용하여 현재 X509Certificate 개체를 바이트 배열로 내보냅니다.

Export(X509ContentType, String)

현재 X509Certificate 개체를 값 중 X509ContentType 하나에서 설명한 형식으로 지정된 암호를 사용하여 바이트 배열로 내보냅니다.

Export(X509ContentType)

값 중 하나에서 설명하는 형식으로 현재 X509Certificate 개체를 바이트 배열로 내보 X509ContentType 냅니다.

public:
 virtual cli::array <System::Byte> ^ Export(System::Security::Cryptography::X509Certificates::X509ContentType contentType);
[System.Runtime.InteropServices.ComVisible(false)]
public virtual byte[] Export(System.Security.Cryptography.X509Certificates.X509ContentType contentType);
public virtual byte[] Export(System.Security.Cryptography.X509Certificates.X509ContentType contentType);
[<System.Runtime.InteropServices.ComVisible(false)>]
abstract member Export : System.Security.Cryptography.X509Certificates.X509ContentType -> byte[]
override this.Export : System.Security.Cryptography.X509Certificates.X509ContentType -> byte[]
abstract member Export : System.Security.Cryptography.X509Certificates.X509ContentType -> byte[]
override this.Export : System.Security.Cryptography.X509Certificates.X509ContentType -> byte[]
Public Overridable Function Export (contentType As X509ContentType) As Byte()

매개 변수

contentType
X509ContentType

X509ContentType 출력 데이터의 형식을 지정하는 방법을 설명하는 값 중 하나입니다.

반품

Byte[]

현재 X509Certificate 개체를 나타내는 바이트 배열입니다.

특성

예외

이외의 CertSerializedCert값이거나 Pkcs12 매개 변수에 contentType 전달되었습니다.

-또는-

인증서를 내보낼 수 없습니다.

예제

다음 예제에서는 X.509 인증서 파일을 개체에 X509Certificate 로드하고 인증서를 바이트 배열로 내보낸 다음 바이트 배열을 다른 X509Certificate 개체로 가져옵니다.

using System;
using System.Security.Cryptography.X509Certificates;

public class X509
{

    public static void Main()
    {

        // The path to the certificate.
        string Certificate = "test.pfx";

        // Load the certificate into an X509Certificate object.
        X509Certificate cert = new X509Certificate(Certificate);

        byte[] certData = cert.Export(X509ContentType.Cert);

        X509Certificate newCert = new X509Certificate(certData);

        // Get the value.
        string resultsTrue = newCert.ToString(true);

        // Display the value to the console.
        Console.WriteLine(resultsTrue);

        // Get the value.
        string resultsFalse = newCert.ToString(false);

        // Display the value to the console.
        Console.WriteLine(resultsFalse);
    }
}
Imports System.Security.Cryptography.X509Certificates


Module X509

    Sub Main()

        ' The path to the certificate.
        Dim Certificate As String = "test.pfx"

        ' Load the certificate into an X509Certificate object.
        Dim cert As New X509Certificate(Certificate)


        Dim certData As Byte() = cert.Export(X509ContentType.Cert)

        Dim newCert As New X509Certificate(certData)

        ' Get the value.
        Dim resultsTrue As String = newCert.ToString(True)

        ' Display the value to the console.
        Console.WriteLine(resultsTrue)

        ' Get the value.
        Dim resultsFalse As String = newCert.ToString(False)

        ' Display the value to the console.
        Console.WriteLine(resultsFalse)

    End Sub
End Module

설명

매개 변수는 contentType 열거형의 X509ContentType 다음 값만 허용합니다. CertSerializedCertPkcs12 다른 값을 전달하면 throw CryptographicException 됩니다.

적용 대상

Export(X509ContentType, SecureString)

Important

이 API는 CLS 규격이 아닙니다.

지정된 형식과 암호를 사용하여 현재 X509Certificate 개체를 바이트 배열로 내보냅니다.

public:
 virtual cli::array <System::Byte> ^ Export(System::Security::Cryptography::X509Certificates::X509ContentType contentType, System::Security::SecureString ^ password);
public virtual byte[] Export(System.Security.Cryptography.X509Certificates.X509ContentType contentType, System.Security.SecureString password);
[System.CLSCompliant(false)]
public virtual byte[] Export(System.Security.Cryptography.X509Certificates.X509ContentType contentType, System.Security.SecureString password);
abstract member Export : System.Security.Cryptography.X509Certificates.X509ContentType * System.Security.SecureString -> byte[]
override this.Export : System.Security.Cryptography.X509Certificates.X509ContentType * System.Security.SecureString -> byte[]
[<System.CLSCompliant(false)>]
abstract member Export : System.Security.Cryptography.X509Certificates.X509ContentType * System.Security.SecureString -> byte[]
override this.Export : System.Security.Cryptography.X509Certificates.X509ContentType * System.Security.SecureString -> byte[]
Public Overridable Function Export (contentType As X509ContentType, password As SecureString) As Byte()

매개 변수

contentType
X509ContentType

X509ContentType 출력 데이터의 형식을 지정하는 방법을 설명하는 값 중 하나입니다.

password
SecureString

X.509 인증서 데이터에 액세스하는 데 필요한 암호입니다.

반품

Byte[]

현재 X509Certificate 개체를 나타내는 바이트 배열입니다.

특성

예외

이외의 CertSerializedCert값이거나 Pkcs12 매개 변수에 contentType 전달되었습니다.

-또는-

인증서를 내보낼 수 없습니다.

설명

매개 변수는 contentType 열거형의 X509ContentType 다음 값만 허용합니다. CertSerializedCertPkcs12 다른 값을 전달하면 throw CryptographicException 됩니다.

Important

소스 코드 내에서 암호를 하드 코딩하지 마세요. 하드 코딩된 암호는 16진수 편집기 인Ildasm.exe(IL 디스어셈블러)를 사용하거나 Notepad.exe같은 텍스트 편집기에서 어셈블리를 열어 어셈블리에서 검색할 수 있습니다.

적용 대상

Export(X509ContentType, String)

현재 X509Certificate 개체를 값 중 X509ContentType 하나에서 설명한 형식으로 지정된 암호를 사용하여 바이트 배열로 내보냅니다.

public:
 virtual cli::array <System::Byte> ^ Export(System::Security::Cryptography::X509Certificates::X509ContentType contentType, System::String ^ password);
[System.Runtime.InteropServices.ComVisible(false)]
public virtual byte[] Export(System.Security.Cryptography.X509Certificates.X509ContentType contentType, string password);
public virtual byte[] Export(System.Security.Cryptography.X509Certificates.X509ContentType contentType, string password);
[<System.Runtime.InteropServices.ComVisible(false)>]
abstract member Export : System.Security.Cryptography.X509Certificates.X509ContentType * string -> byte[]
override this.Export : System.Security.Cryptography.X509Certificates.X509ContentType * string -> byte[]
abstract member Export : System.Security.Cryptography.X509Certificates.X509ContentType * string -> byte[]
override this.Export : System.Security.Cryptography.X509Certificates.X509ContentType * string -> byte[]
Public Overridable Function Export (contentType As X509ContentType, password As String) As Byte()

매개 변수

contentType
X509ContentType

X509ContentType 출력 데이터의 형식을 지정하는 방법을 설명하는 값 중 하나입니다.

password
String

X.509 인증서 데이터에 액세스하는 데 필요한 암호입니다.

반품

Byte[]

현재 X509Certificate 개체를 나타내는 바이트 배열입니다.

특성

예외

이외의 CertSerializedCert값이거나 Pkcs12 매개 변수에 contentType 전달되었습니다.

-또는-

인증서를 내보낼 수 없습니다.

설명

매개 변수는 contentType 열거형의 X509ContentType 다음 값만 허용합니다. CertSerializedCertPkcs12 다른 값을 전달하면 throw CryptographicException 됩니다.

Important

소스 코드 내에서 암호를 하드 코딩하지 마세요. 하드 코딩된 암호는 16진수 편집기 인Ildasm.exe(IL 디스어셈블러)를 사용하거나 Notepad.exe같은 텍스트 편집기에서 어셈블리를 열어 어셈블리에서 검색할 수 있습니다.

적용 대상