mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-05 20:13:44 +02:00
Test certificate copy/construct.
This commit is contained in:
parent
6af39da61a
commit
9029570452
3 changed files with 17 additions and 14 deletions
|
@ -185,6 +185,14 @@ void Certificate::addSubjectUpdateUrl(const char *url)
|
|||
this->subject.updateUrlCount = (unsigned int)m_updateUrls.size();
|
||||
}
|
||||
|
||||
void Certificate::setExtendedAttributes(const Dictionary &x)
|
||||
{
|
||||
m_extendedAttributes.clear();
|
||||
x.encode(m_extendedAttributes);
|
||||
this->extendedAttributes = m_extendedAttributes.data();
|
||||
this->extendedAttributesSize = (unsigned int)m_extendedAttributes.size();
|
||||
}
|
||||
|
||||
Vector< uint8_t > Certificate::encode(const bool omitSignature) const
|
||||
{
|
||||
Vector< uint8_t > enc;
|
||||
|
|
|
@ -48,16 +48,12 @@ namespace ZeroTier {
|
|||
class Certificate : public ZT_Certificate
|
||||
{
|
||||
friend class SharedPtr< Certificate >;
|
||||
|
||||
friend class SharedPtr< const Certificate >;
|
||||
|
||||
public:
|
||||
Certificate() noexcept;
|
||||
|
||||
Certificate(const ZT_Certificate &apiCert);
|
||||
|
||||
Certificate(const Certificate &cert);
|
||||
|
||||
~Certificate();
|
||||
|
||||
Certificate &operator=(const ZT_Certificate &cert);
|
||||
|
@ -116,13 +112,7 @@ public:
|
|||
*
|
||||
* @param x Extended attributes (set by issuer)
|
||||
*/
|
||||
ZT_INLINE void setExtendedAttributes(const Dictionary &x)
|
||||
{
|
||||
m_extendedAttributes.clear();
|
||||
x.encode(m_extendedAttributes);
|
||||
this->extendedAttributes = m_extendedAttributes.data();
|
||||
this->extendedAttributesSize = (unsigned int)m_extendedAttributes.size();
|
||||
}
|
||||
void setExtendedAttributes(const Dictionary &x);
|
||||
|
||||
/**
|
||||
* Marshal this certificate in binary form
|
||||
|
|
|
@ -1161,9 +1161,14 @@ extern "C" const char *ZTT_crypto()
|
|||
return "Verify decoded certificate";
|
||||
}
|
||||
ZT_T_PRINTF("OK" ZT_EOL_S);
|
||||
|
||||
cert.zero();
|
||||
cert2.zero();
|
||||
|
||||
ZT_T_PRINTF(" Test certificate copy/construct... ");
|
||||
SharedPtr<Certificate> cert3(new Certificate(*cert2));
|
||||
if (!ZTT_deepCompareCertificates(*cert2, *cert3)) {
|
||||
ZT_T_PRINTF("FAILED (compare copy with original)" ZT_EOL_S);
|
||||
return "Certificate copy";
|
||||
}
|
||||
ZT_T_PRINTF("OK" ZT_EOL_S);
|
||||
}
|
||||
} catch (std::exception &e) {
|
||||
ZT_T_PRINTF(ZT_EOL_S "[crypto] Unexpected exception: %s" ZT_EOL_S, e.what());
|
||||
|
|
Loading…
Add table
Reference in a new issue