12 #include "../util/time.hpp"
14 #include "../encoding/cryptopp/asn_ext.hpp"
20 Certificate::Certificate()
21 : m_notBefore(time::system_clock::TimePoint::max())
22 , m_notAfter(time::system_clock::TimePoint::min())
94 using namespace CryptoPP;
97 CryptoPP::FileSink sink(os);
104 DERSequenceEncoder idCert(sink);
109 DERSequenceEncoder validity(idCert);
114 validity.MessageEnd();
120 DERSequenceEncoder name(idCert);
141 DERSequenceEncoder extensions(idCert);
146 it->encode(extensions);
149 extensions.MessageEnd();
162 using namespace CryptoPP;
172 BERSequenceDecoder idCert(source);
177 BERSequenceDecoder validity(idCert);
182 validity.MessageEnd();
189 BERSequenceDecoder name(idCert);
191 while (!name.EndReached())
210 if (!idCert.EndReached())
212 BERSequenceDecoder extensions(idCert);
214 while (!extensions.EndReached())
219 extensions.MessageEnd();
229 os <<
"Certificate name:" << endl;
230 os <<
" " <<
getName() << endl;
231 os <<
"Validity:" << endl;
237 os <<
"Subject Description:" << endl;
241 os <<
" " << it->getOidString() <<
": " << it->getValue() << endl;
244 os <<
"Public key bits:" << endl;
245 CryptoPP::Base64Encoder encoder(
new CryptoPP::FileSink(os),
true, 64);
Class implementing interface similar to ostringstream, but to construct ndn::Buffer.
ExtensionList m_extensionList
size_t DEREncodeGeneralTime(CryptoPP::BufferedTransformation &bt, const time::system_clock::TimePoint &time)
void setContentType(uint32_t type)
A CertificateSubjectDescription represents the SubjectDescription entry in a Certificate.
void encode(CryptoPP::BufferedTransformation &out) const
Certificate()
The default constructor.
const Name & getName() const
time::system_clock::TimePoint m_notAfter
void setContent(const uint8_t *content, size_t contentLength)
Set the content to a copy of the data in the vector.
void BERDecodeTime(CryptoPP::BufferedTransformation &bt, time::system_clock::TimePoint &time)
bool isTooLate()
Check if the certificate is valid.
void encode()
encode certificate info into content
time::system_clock::TimePoint m_notBefore
std::string toIsoString(const system_clock::TimePoint &timePoint)
Convert to the ISO string representation of the time (YYYYMMDDTHHMMSS,fffffffff)
bool isTooEarly()
Check if the certificate is valid.
void decode(CryptoPP::BufferedTransformation &in)
SubjectDescriptionList m_subjectDescriptionList
const Block & getContent() const
Get content Block.
virtual ~Certificate()
The virtual destructor.
A CertificateExtension represents the Extension entry in a certificate.
void printCertificate(std::ostream &os) const