@@ -208,7 +208,7 @@ void X509Certificate::save(const std::string& path) const
208208}
209209
210210
211- std::string _X509_NAME_oneline_utf8 (X509_NAME *name)
211+ std::string _X509_NAME_oneline_utf8 (const X509_NAME *name)
212212{
213213 BIO * bio_out = BIO_new (BIO_s_mem ());
214214 X509_NAME_print_ex (bio_out, name, 0 , (ASN1_STRFLGS_RFC2253 | XN_FLAG_SEP_COMMA_PLUS | XN_FLAG_FN_SN | XN_FLAG_DUMP_UNKNOWN_FIELDS) & ~ASN1_STRFLGS_ESC_MSB);
@@ -246,7 +246,7 @@ std::string X509Certificate::commonName() const
246246
247247std::string X509Certificate::issuerName (NID nid) const
248248{
249- if (X509_NAME* issuer = X509_get_issuer_name (_pCert))
249+ if (auto issuer = X509_get_issuer_name (_pCert))
250250 {
251251 char buffer[NAME_BUFFER_SIZE];
252252 if (X509_NAME_get_text_by_NID (issuer, nid, buffer, sizeof (buffer)) >= 0 )
@@ -258,7 +258,7 @@ std::string X509Certificate::issuerName(NID nid) const
258258
259259std::string X509Certificate::subjectName (NID nid) const
260260{
261- if (X509_NAME* subj = X509_get_subject_name (_pCert))
261+ if (auto subj = X509_get_subject_name (_pCert))
262262 {
263263 char buffer[NAME_BUFFER_SIZE];
264264 if (X509_NAME_get_text_by_NID (subj, nid, buffer, sizeof (buffer)) >= 0 )
@@ -296,13 +296,14 @@ void X509Certificate::extractNames(std::string& cmnName, std::set<std::string>&
296296Poco::DateTime X509Certificate::validFrom () const
297297{
298298 const ASN1_TIME* certTime = X509_get0_notBefore (_pCert);
299- std::string dateTime (reinterpret_cast <char *>(certTime->data ));
299+ auto certTimeType = ASN1_STRING_type (certTime);
300+ std::string dateTime (reinterpret_cast <const char *>(ASN1_STRING_get0_data (certTime)), ASN1_STRING_length (certTime));
300301 int tzd;
301- if (certTime-> type == V_ASN1_UTCTIME)
302+ if (certTimeType == V_ASN1_UTCTIME)
302303 {
303304 return DateTimeParser::parse (" %y%m%d%H%M%S" , dateTime, tzd);
304305 }
305- else if (certTime-> type == V_ASN1_GENERALIZEDTIME)
306+ else if (certTimeType == V_ASN1_GENERALIZEDTIME)
306307 {
307308 return DateTimeParser::parse (" %Y%m%d%H%M%S" , dateTime, tzd);
308309 }
@@ -316,13 +317,14 @@ Poco::DateTime X509Certificate::validFrom() const
316317Poco::DateTime X509Certificate::expiresOn () const
317318{
318319 const ASN1_TIME* certTime = X509_get0_notAfter (_pCert);
319- std::string dateTime (reinterpret_cast <char *>(certTime->data ));
320+ auto certTimeType = ASN1_STRING_type (certTime);
321+ std::string dateTime (reinterpret_cast <const char *>(ASN1_STRING_get0_data (certTime)), ASN1_STRING_length (certTime));
320322 int tzd;
321- if (certTime-> type == V_ASN1_UTCTIME)
323+ if (certTimeType == V_ASN1_UTCTIME)
322324 {
323325 return DateTimeParser::parse (" %y%m%d%H%M%S" , dateTime, tzd);
324326 }
325- else if (certTime-> type == V_ASN1_GENERALIZEDTIME)
327+ else if (certTimeType == V_ASN1_GENERALIZEDTIME)
326328 {
327329 return DateTimeParser::parse (" %Y%m%d%H%M%S" , dateTime, tzd);
328330 }
0 commit comments