---
title: "System::Security::Cryptography::X509Certificates::X509Certificate2::set_PrivateKey method"
url: "https://reference.aspose.com/tex/cpp/system.security.cryptography.x509certificates/x509certificate2/set_privatekey/"
product: "Aspose.TeX for C++"
description: "System::Security::Cryptography::X509Certificates::X509Certificate2::set_PrivateKey method. Sets or clears private key associated with certificate in C++."
---

## X509Certificate2::set_PrivateKey method


Sets or clears private key associated with certificate.

```cpp
void System::Security::Cryptography::X509Certificates::X509Certificate2::set_PrivateKey(const SharedPtr<AsymmetricAlgorithm> &value)
```


| Parameter | Type | Description |
| --- | --- | --- |
| value | const SharedPtr\<AsymmetricAlgorithm\>\& | Private key object (or nullptr to unset). |

## See Also

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