
/*
 * Copyright 2011-2022 Cuberite Contributors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

// X509Cert.h

// Declares the cX509Cert class representing a wrapper over X509 certs in mbedTLS





#pragma once

#include "mbedtls/x509_crt.h"





class cX509Cert
{
	friend class cSslConfig;

public:
	cX509Cert(void);
	~cX509Cert(void);

	/** Parses the certificate chain data into the context.
	The certificate can be DER- or PEM-encoded.
	Returns 0 on succes, or mbedTLS error code on failure. */
	int Parse(const void * a_CertContents, size_t a_Size);

protected:
	mbedtls_x509_crt m_Cert;

	/** Returns the internal cert ptr. Only use in mbedTLS API calls. */
	mbedtls_x509_crt * GetInternal(void) { return &m_Cert; }
} ;

typedef std::shared_ptr<cX509Cert> cX509CertPtr;




