+ ssl_cert* get(const Extensible* item) const
+ {
+ return static_cast<ssl_cert*>(get_raw(item));
+ }
+ void set(Extensible* item, ssl_cert* value)
+ {
+ value->refcount_inc();
+ ssl_cert* old = static_cast<ssl_cert*>(set_raw(item, value));
+ if (old && old->refcount_dec())
+ delete old;
+ }
+
+ std::string serialize(SerializeFormat format, const Extensible* container, void* item) const
+ {
+ return static_cast<ssl_cert*>(item)->GetMetaLine();
+ }
+
+ void unserialize(SerializeFormat format, Extensible* container, const std::string& value)
+ {
+ ssl_cert* cert = new ssl_cert;
+ set(container, cert);
+
+ std::stringstream s(value);
+ std::string v;
+ getline(s,v,' ');
+
+ cert->invalid = (v.find('v') != std::string::npos);
+ cert->trusted = (v.find('T') != std::string::npos);
+ cert->revoked = (v.find('R') != std::string::npos);
+ cert->unknownsigner = (v.find('s') != std::string::npos);
+ if (v.find('E') != std::string::npos)
+ {
+ getline(s,cert->error,'\n');
+ }
+ else
+ {
+ getline(s,cert->fingerprint,' ');
+ getline(s,cert->dn,' ');
+ getline(s,cert->issuer,'\n');
+ }
+ }
+
+ void free(void* item)
+ {
+ ssl_cert* old = static_cast<ssl_cert*>(item);
+ if (old && old->refcount_dec())
+ delete old;
+ }
+};