X509Certificate.Export 메서드

정의

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

오버로드

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);
public virtual byte[] Export (System.Security.Cryptography.X509Certificates.X509ContentType contentType);
[System.Runtime.InteropServices.ComVisible(false)]
public virtual byte[] Export (System.Security.Cryptography.X509Certificates.X509ContentType contentType);
abstract member Export : System.Security.Cryptography.X509Certificates.X509ContentType -> byte[]
override this.Export : System.Security.Cryptography.X509Certificates.X509ContentType -> byte[]
[<System.Runtime.InteropServices.ComVisible(false)>]
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 개체를 나타내는 바이트의 배열입니다.

특성

예외

Cert, SerializedCert 또는 Pkcs12 이외의 값이 contentType 매개 변수로 전달된 경우

또는 인증서를 내보낼 수 없는 경우

예제

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

using namespace System;
using namespace System::Security::Cryptography::X509Certificates;
int main()
{
   
   // The path to the certificate.
   String^ Certificate = L"test.pfx";
   
   // Load the certificate into an X509Certificate object.
   X509Certificate^ cert = gcnew X509Certificate( Certificate );
   array<Byte>^certData = cert->Export( X509ContentType::Cert );
   X509Certificate^ newCert = gcnew 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 );
}
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)

중요

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

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

public:
 virtual cli::array <System::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);
[System.CLSCompliant(false)]
public virtual 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)>]
abstract member Export : System.Security.Cryptography.X509Certificates.X509ContentType * System.Security.SecureString -> byte[]
override this.Export : System.Security.Cryptography.X509Certificates.X509ContentType * System.Security.SecureString -> byte[]
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 개체를 나타내는 바이트 배열입니다.

특성

예외

Cert, SerializedCert 또는 Pkcs12 이외의 값이 contentType 매개 변수로 전달된 경우

또는 인증서를 내보낼 수 없는 경우

설명

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

중요

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

적용 대상

Export(X509ContentType, String)

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

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

매개 변수

contentType
X509ContentType

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

password
String

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

반환

Byte[]

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

특성

예외

Cert, SerializedCert 또는 Pkcs12 이외의 값이 contentType 매개 변수로 전달된 경우

또는 인증서를 내보낼 수 없는 경우

설명

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

중요

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

적용 대상