Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
PKI/Certificate.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
7#include "Stroika/Foundation/Cryptography/Providers/OpenSSL/Certificate.h"
8#else
9#include "Stroika/Foundation/Execution/RequiredComponentMissingException.h"
10#endif
11
13
14#include "Certificate.h"
15
16using namespace Stroika::Foundation;
18using namespace Stroika::Foundation::Cryptography;
19#if !qStroika_HasComponent_OpenSSL
20using namespace Stroika::Foundation::Execution;
21#endif
22
23/*
24 ********************************************************************************
25 *********************** Cryptography::Certificate::Ptr *************************
26 ********************************************************************************
27 */
28String Cryptography::PKI::Certificate::SubjectInfo::ToString () const
29{
31 sb << "{"sv;
32 sb << "country: "sv << fCountry;
33 sb << ", organization: "sv << fOrganization;
34 sb << ", commonName: "sv << fCommonName;
35 sb << "}"sv;
36 return sb;
37}
38
39/*
40 ********************************************************************************
41 *********************** Cryptography::Certificate::Ptr *************************
42 ********************************************************************************
43 */
44auto Cryptography::PKI::Certificate::Ptr::ToString () const -> String
45{
46 if (*this == nullptr) {
47 return "nullptr"sv;
48 }
50 sb << "{"sv;
51 sb << "subject: "sv << this->GetSubject ();
52 sb << ", valid-dates: "sv << this->GetValidDates ();
53 sb << "}"sv;
54 return sb;
55}
56
57/*
58 ********************************************************************************
59 ************************ Cryptography::Certificate::New ************************
60 ********************************************************************************
61 */
62auto Cryptography::PKI::Certificate::New (const SelfSignedCertParams& params) -> tuple<Cryptography::PKI::PrivateKey::Ptr, Ptr>
63{
64#if qStroika_HasComponent_OpenSSL
65 return Cryptography::Providers::OpenSSL::Certificate::New (params);
66#else
67 Throw (RequiredComponentMissingException{"SSL providing service"sv});
68#endif
69}
Similar to String, but intended to more efficiently construct a String. Mutable type (String is large...
String is like std::u32string, except it is much easier to use, often much more space efficient,...
Definition String.h:201
void Throw(T &&e2Throw)
identical to builtin C++ 'throw' except that it does helpful, type dependent DbgTrace() messages firs...
Definition Throw.inl:43