# Poco::Net

# class X509Certificate

Library: NetSSL_OpenSSL
Package: SSLCore
Header: Poco/Net/X509Certificate.h

## Description

This class extends Poco::Crypto::X509Certificate with the feature to validate a certificate.

## Inheritance

Direct Base Classes: Poco::Crypto::X509Certificate

All Base Classes: Poco::Crypto::X509Certificate

## Member Summary

Member Functions: containsWildcards, matchByAlias, operator =, verify

Inherited Functions: certificate, commonName, expiresOn, extractNames, init, issuedBy, issuerName, load, operator =, save, subjectName, swap, validFrom

## Constructors

### X509Certificate

explicit X509Certificate(
std::istream & istr
);

Creates the X509Certificate object by reading a certificate in PEM format from a stream.

### X509Certificate

explicit X509Certificate(
const std::string & path
);

Creates the X509Certificate object by reading a certificate in PEM format from a file.

### X509Certificate

explicit X509Certificate(
X509 * pCert
);

Creates the X509Certificate from an existing OpenSSL certificate. Ownership is taken of the certificate.

### X509Certificate

X509Certificate(
const Poco::Crypto::X509Certificate & cert
);

Creates the certificate by copying another one.

### X509Certificate

X509Certificate(
X509 * pCert,
bool shared
);

Creates the X509Certificate from an existing OpenSSL certificate. Ownership is taken of the certificate. If shared is true, the certificate's reference count is incremented.

## Destructor

### ~X509Certificate

~X509Certificate();

Destroys the X509Certificate.

## Member Functions

### operator =

X509Certificate & operator = (
const Poco::Crypto::X509Certificate & cert
);

Assigns a certificate.

### verify

bool verify(
const std::string & hostName
) const;

Verifies the validity of the certificate against the host name.

For this check to be successful, the certificate must contain a domain name that matches the domain name of the host.

Returns true if verification succeeded, or false otherwise.

### verify

static bool verify(
const Poco::Crypto::X509Certificate & cert,
const std::string & hostName
);

Verifies the validity of the certificate against the host name.

For this check to be successful, the certificate must contain a domain name that matches the domain name of the host.

Returns true if verification succeeded, or false otherwise.

### containsWildcards

static bool containsWildcards(
const std::string & commonName
);

### matchByAlias

static bool matchByAlias(
const std::string & alias,
const HostEntry & heData
);