I am trying to read the USB token certificate details like the day after, the day before and subject, and other details from the certificate on the USB token I am using Botan 2.19 library and PKCS11 I have success in login and also set the bin but I can't get certificate details my trial is
session.login(Botan::PKCS11::UserType::User, pin);
Botan::PKCS11::Slot slot(module, slotsx[0]);
Botan::PKCS11::Session session(slot, false);
Botan::PKCS11::secure_string pin = {'1', '1', '1', '1', '2', '2', '2', '2'};
session.login(Botan::PKCS11::UserType::User, pin);
// Retrieve the certificate objects from the token
std::vector<Botan::PKCS11::ObjectHandle> cert_objects = module->C_FindObjects(slot, Botan::PKCS11::ObjectClass::Certificate);
if (!cert_objects.empty()) {
// Assuming you want to read the first certificate on the token
Botan::PKCS11::ObjectHandle cert_object = cert_objects[0];
// Get the certificate data as a binary DER format
std::vector<uint8_t> der_data = session.get_attribute_value(cert_object, Botan::PKCS11::AttributeType::Value);
// Parse the certificate from DER data
Botan::DataSource_Memory cert_source(der_data.data(), der_data.size());
Botan::X509_Certificate cert(cert_source);
// Access certificate information
std::cout << "Certificate subject: " << cert.subject_dn().to_string() << std::endl;
std::cout << "Certificate issuer: " << cert.issuer_dn().to_string() << std::endl;
std::cout << "Certificate serial number: " << cert.serial_number() << std::endl;
std::cout << "Certificate not valid before: " << cert.not_before() << std::endl;
std::cout << "Certificate not valid after: " << cert.not_after() << std::endl;
can anyone help me to find a solution to read the certificate data?