---
title: "System::Security::Cryptography::X509Certificates::X509Certificate2::get_PrivateKey method"
url: "https://reference.aspose.com/pub/cpp/system.security.cryptography.x509certificates/x509certificate2/get_privatekey/"
product: "Aspose.PUB for C++"
description: "System::Security::Cryptography::X509Certificates::X509Certificate2::get_PrivateKey method. Gets private key associated with certificate in C++."
---

## X509Certificate2::get_PrivateKey method


Gets private key associated with certificate.

```cpp
SharedPtr<AsymmetricAlgorithm> System::Security::Cryptography::X509Certificates::X509Certificate2::get_PrivateKey() const
```


### ReturnValue

Private key object (or nullptr if unset).

## See Also

* Typedef [SharedPtr](../../../system/sharedptr/)
* Class [AsymmetricAlgorithm](../../../system.security.cryptography/asymmetricalgorithm/)
* Class [X509Certificate2](../)
* Namespace [System::Security::Cryptography::X509Certificates](../../)
* Library [Aspose.PUB for C++](../../../)
