Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
PEMFile.h File Reference

a PEM File is a data structure commonly used to store private keys, and or certificates (as well as several other things not currently supported here). More...

#include "Stroika/Foundation/StroikaPreComp.h"
#include <filesystem>
#include "Stroika/Foundation/Characters/String.h"
#include "Stroika/Foundation/Containers/Sequence.h"
#include "Stroika/Foundation/Cryptography/PKI/Certificate.h"
#include "Stroika/Foundation/Cryptography/PKI/PrivateKey.h"
#include "Stroika/Foundation/Memory/BLOB.h"
#include "PEMFile.inl"

Go to the source code of this file.

Namespaces

namespace  Stroika::Foundation
 

Typedefs

using Stroika::Foundation::Cryptography::PKI::PEMFile::EntryType = variant< Certificate::Ptr, PrivateKey::Ptr >
 

Functions

Ptr Stroika::Foundation::Cryptography::PKI::PEMFile::New (const filesystem::path &pemFile)
 

Detailed Description

a PEM File is a data structure commonly used to store private keys, and or certificates (as well as several other things not currently supported here).

At this level of abstraction - its just a bunch of bytes, but used in overloading, in other APIs, so they correctly know how to interpret the bytes.

https://datatracker.ietf.org/doc/html/rfc7468

Definition in file PKI/PEMFile.h.

Typedef Documentation

◆ EntryType

using Stroika::Foundation::Cryptography::PKI::PEMFile::EntryType = typedef variant<Certificate::Ptr, PrivateKey::Ptr>
Note
since this is being developed to support webserver, main target support is PrivateKey/Cert –LGP 2025-01-03

Definition at line 40 of file PKI/PEMFile.h.

Function Documentation

◆ New()

auto Stroika::Foundation::Cryptography::PKI::PEMFile::New ( const filesystem::path &  pemFile)
Example Usage:
PEMFile::Ptr myCertPem{New (IO::FileSystem::FileInputStream::New ("my-cert.pem").ReadAll ()))};
Certificate::Ptr cert = pem.GetByType<Certificate::Ptr> ().FirstValue (nullptr);
PrivateKey::Ptr pkey = pem.GetByType<PrivateKey::Ptr> ().FirstValue (nullptr);
Example Usage:
PEMFile::Ptr myCertPem{"my-cert.pem"}; // same as above example, uses FileInputStream::New as above
Example Usage:
auto [pk, cert] = Certificate::New (Certificate::SelfSignedCertParams{
.fValidDates = validDates, .fSubject = {.fCountry = "US"sv, .fOrganization = company, .fCommonName = commonName}});
// construct from existing collection of certs, and private keys
PEMFile::Ptr pem = PEMFile::New ({pk, cert});

Definition at line 39 of file PKI/PEMFile.cpp.