Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
PKI/PEMFile.cpp
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3 */
4#include "Stroika/Foundation/StroikaPreComp.h"
5
6#if qStroika_HasComponent_OpenSSL
8#else
9#include "Stroika/Foundation/Execution/RequiredComponentMissingException.h"
10#endif
13
14#include "PEMFile.h"
15
16using namespace Stroika::Foundation;
17using namespace Stroika::Foundation::Cryptography;
18using namespace Stroika::Foundation::Cryptography::PKI;
19#if !qStroika_HasComponent_OpenSSL
20using namespace Stroika::Foundation::Execution;
21#endif
22using namespace Stroika::Foundation::Streams;
23
24/*
25 ********************************************************************************
26 ****************************** PKI::PEMFile::Ptr *******************************
27 ********************************************************************************
28 */
29Characters::String PEMFile::Ptr::ToString () const
30{
31 return BinaryToText::Convert (get ()->GetData ());
32}
33
34/*
35 ********************************************************************************
36 ********************************* PKI::PEMFile *********************************
37 ********************************************************************************
38 */
39auto PKI::PEMFile::New (const filesystem::path& pemFile) -> Ptr
40{
41 return New (IO::FileSystem::FileInputStream::New (pemFile).ReadAll ());
42}
43auto PKI::PEMFile::New (const Memory::BLOB& pemData) -> Ptr
44{
45#if qStroika_HasComponent_OpenSSL
46 return Cryptography::Providers::OpenSSL::PEMFile::New (pemData);
47#else
48 Throw (RequiredComponentMissingException{"SSL providing service"sv});
49#endif
50}
51auto PKI::PEMFile::New (const Sequence<EntryType>& entries) -> Ptr
52{
53#if qStroika_HasComponent_OpenSSL
54 return Cryptography::Providers::OpenSSL::PEMFile::New (entries);
55#else
56 Throw (RequiredComponentMissingException{"SSL providing service"sv});
57#endif
58}
String is like std::u32string, except it is much easier to use, often much more space efficient,...
Definition String.h:201
A generalization of a vector: a container whose elements are keyed by the natural numbers.
Definition Sequence.h:187
A Streams::Ptr<ELEMENT_TYPE> is a smart-pointer to a stream of elements of type T.
Definition Stream.h:170
void Throw(T &&e2Throw)
identical to builtin C++ 'throw' except that it does helpful, type dependent DbgTrace() messages firs...
Definition Throw.inl:43