mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-06 20:43: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();
|
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 > Certificate::encode(const bool omitSignature) const
|
||||||
{
|
{
|
||||||
Vector< uint8_t > enc;
|
Vector< uint8_t > enc;
|
||||||
|
|
|
@ -48,16 +48,12 @@ namespace ZeroTier {
|
||||||
class Certificate : public ZT_Certificate
|
class Certificate : public ZT_Certificate
|
||||||
{
|
{
|
||||||
friend class SharedPtr< Certificate >;
|
friend class SharedPtr< Certificate >;
|
||||||
|
|
||||||
friend class SharedPtr< const Certificate >;
|
friend class SharedPtr< const Certificate >;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Certificate() noexcept;
|
Certificate() noexcept;
|
||||||
|
|
||||||
Certificate(const ZT_Certificate &apiCert);
|
Certificate(const ZT_Certificate &apiCert);
|
||||||
|
|
||||||
Certificate(const Certificate &cert);
|
Certificate(const Certificate &cert);
|
||||||
|
|
||||||
~Certificate();
|
~Certificate();
|
||||||
|
|
||||||
Certificate &operator=(const ZT_Certificate &cert);
|
Certificate &operator=(const ZT_Certificate &cert);
|
||||||
|
@ -116,13 +112,7 @@ public:
|
||||||
*
|
*
|
||||||
* @param x Extended attributes (set by issuer)
|
* @param x Extended attributes (set by issuer)
|
||||||
*/
|
*/
|
||||||
ZT_INLINE void setExtendedAttributes(const Dictionary &x)
|
void setExtendedAttributes(const Dictionary &x);
|
||||||
{
|
|
||||||
m_extendedAttributes.clear();
|
|
||||||
x.encode(m_extendedAttributes);
|
|
||||||
this->extendedAttributes = m_extendedAttributes.data();
|
|
||||||
this->extendedAttributesSize = (unsigned int)m_extendedAttributes.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Marshal this certificate in binary form
|
* Marshal this certificate in binary form
|
||||||
|
|
|
@ -1161,9 +1161,14 @@ extern "C" const char *ZTT_crypto()
|
||||||
return "Verify decoded certificate";
|
return "Verify decoded certificate";
|
||||||
}
|
}
|
||||||
ZT_T_PRINTF("OK" ZT_EOL_S);
|
ZT_T_PRINTF("OK" ZT_EOL_S);
|
||||||
|
|
||||||
cert.zero();
|
ZT_T_PRINTF(" Test certificate copy/construct... ");
|
||||||
cert2.zero();
|
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) {
|
} catch (std::exception &e) {
|
||||||
ZT_T_PRINTF(ZT_EOL_S "[crypto] Unexpected exception: %s" ZT_EOL_S, e.what());
|
ZT_T_PRINTF(ZT_EOL_S "[crypto] Unexpected exception: %s" ZT_EOL_S, e.what());
|
||||||
|
|
Loading…
Add table
Reference in a new issue