QSslCertificate Class
QSslCertificate 클래스는 X509 인증서를 위한 편리한 API를 제공합니다. 더 보기...
헤더: | #include <QSslCertificate> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS Network) target_link_libraries(mytarget PRIVATE Qt6::Network) |
qmake: | QT += network |
- 상속된 멤버를 포함한 모든 멤버 목록
- QSslCertificate는 네트워크 프로그래밍 API 및 암시적으로 공유되는 클래스의 일부입니다.
참고: 이 클래스의 모든 함수는 재진입됩니다.
공용 유형
enum class | PatternSyntax { RegularExpression, Wildcard, FixedString } |
enum | SubjectInfo { Organization, CommonName, LocalityName, OrganizationalUnitName, CountryName, …, EmailAddress } |
공용 함수
QSslCertificate(QIODevice *device, QSsl::EncodingFormat format = QSsl::Pem) | |
QSslCertificate(const QByteArray &data = QByteArray(), QSsl::EncodingFormat format = QSsl::Pem) | |
QSslCertificate(const QSslCertificate &other) | |
(since 6.8) | QSslCertificate(QSslCertificate &&other) |
~QSslCertificate() | |
void | clear() |
QByteArray | digest(QCryptographicHash::Algorithm algorithm = QCryptographicHash::Md5) const |
QDateTime | effectiveDate() const |
QDateTime | expiryDate() const |
QList<QSslCertificateExtension> | extensions() const |
Qt::HANDLE | handle() const |
bool | isBlacklisted() const |
bool | isNull() const |
bool | isSelfSigned() const |
QString | issuerDisplayName() const |
QStringList | issuerInfo(QSslCertificate::SubjectInfo subject) const |
QStringList | issuerInfo(const QByteArray &attribute) const |
QList<QByteArray> | issuerInfoAttributes() const |
QSslKey | publicKey() const |
QByteArray | serialNumber() const |
QMultiMap<QSsl::AlternativeNameEntryType, QString> | subjectAlternativeNames() const |
QString | subjectDisplayName() const |
QStringList | subjectInfo(QSslCertificate::SubjectInfo subject) const |
QStringList | subjectInfo(const QByteArray &attribute) const |
QList<QByteArray> | subjectInfoAttributes() const |
void | swap(QSslCertificate &other) |
QByteArray | toDer() const |
QByteArray | toPem() const |
QString | toText() const |
QByteArray | version() const |
bool | operator!=(const QSslCertificate &other) const |
QSslCertificate & | operator=(const QSslCertificate &other) |
bool | operator==(const QSslCertificate &other) const |
정적 공용 멤버
QList<QSslCertificate> | fromData(const QByteArray &data, QSsl::EncodingFormat format = QSsl::Pem) |
QList<QSslCertificate> | fromDevice(QIODevice *device, QSsl::EncodingFormat format = QSsl::Pem) |
QList<QSslCertificate> | fromPath(const QString &path, QSsl::EncodingFormat format = QSsl::Pem, QSslCertificate::PatternSyntax syntax = PatternSyntax::FixedString) |
bool | importPkcs12(QIODevice *device, QSslKey *key, QSslCertificate *certificate, QList<QSslCertificate> *caCertificates = nullptr, const QByteArray &passPhrase = QByteArray()) |
QList<QSslError> | verify(const QList<QSslCertificate> &certificateChain, const QString &hostName = QString()) |
상세 설명
QSslCertificate는 X509 인증서를 저장하며, 일반적으로 로컬 호스트, 원격으로 연결된 피어 또는 신뢰할 수 있는 타사 인증 기관에 대한 신원을 확인하고 정보를 저장하는 데 사용됩니다.
QSslCertificate를 만드는 방법은 여러 가지가 있습니다. 가장 일반적인 방법은 QSslSocket::peerCertificate()를 호출하여 QSslCertificate 개체를 반환하거나 QSslSocket::peerCertificateChain()를 호출하여 목록을 반환하는 것입니다. 일반적으로 하나 이상의 로컬 파일로 저장된 DER(바이너리) 또는 PEM(Base64) 인코딩된 번들 또는 Qt 리소스에서 인증서를 로드할 수도 있습니다.
isNull()를 호출하여 인증서가 null인지 확인할 수 있습니다. 기본적으로 QSslCertificate는 null 인증서를 만듭니다. 널 인증서는 유효하지 않지만 유효하지 않은 인증서가 반드시 널인 것은 아닙니다. 인증서의 모든 내용을 재설정하려면 clear()를 호출합니다.
인증서를 로드한 후 version(), serialNumber(), issuerInfo() 및 subjectInfo()를 포함한 여러 접근자 함수 중 하나를 호출하여 인증서, 주체 및 발급자에 대한 정보를 찾을 수 있습니다. effectiveDate () 및 expiryDate()를 호출하여 인증서의 유효 기간이 언제 시작되고 언제 만료되는지 확인할 수 있습니다. publicKey () 함수는 인증서 주체의 공개 키를 QSslKey 로 반환합니다. issuerInfo() 또는 subjectInfo()를 호출하여 인증서 발급자 및 주체에 대한 자세한 정보를 얻을 수 있습니다.
내부적으로 QSslCertificate는 X509 구조로 저장됩니다. handle ()를 호출하여 이 핸들에 액세스할 수 있지만 결과는 이식되지 않을 수 있습니다.
QSslSocket, QSslKey, QSslCipher, QSslError 을참조하세요 .
멤버 유형 문서
enum class QSslCertificate::PatternSyntax
패턴의 의미를 해석하는 데 사용되는 구문입니다.
Constant | 값 | 설명 |
---|---|---|
QSslCertificate::PatternSyntax::RegularExpression | 0 | Perl과 유사한 풍부한 패턴 일치 구문입니다. |
QSslCertificate::PatternSyntax::Wildcard | 1 | 셸(명령 인터프리터)에서 "파일 글로빙"에 사용하는 것과 유사한 간단한 패턴 일치 구문을 제공합니다. QRegularExpression::fromWildcard ()를 참조하세요. |
QSslCertificate::PatternSyntax::FixedString | 2 | 패턴은 고정 문자열입니다. 이는 모든 메타문자가 escape()를 사용하여 이스케이프 처리되는 문자열에 정규 표현식 패턴을 사용하는 것과 같습니다. 이것이 기본값입니다. |
enum QSslCertificate::SubjectInfo
인증서 발급자 또는 주체에 대한 정보를 얻기 위해 QSslCertificate::issuerInfo() 또는 QSslCertificate::subjectInfo()에 전달할 수 있는 키를 설명합니다.
상수 | 값 | 설명 |
---|---|---|
QSslCertificate::Organization | 0 | "O" 조직의 이름입니다. |
QSslCertificate::CommonName | 1 | "CN" 일반 이름; 대부분 호스트 이름을 저장하는 데 사용됩니다. |
QSslCertificate::LocalityName | 2 | "L" 지역입니다. |
QSslCertificate::OrganizationalUnitName | 3 | "OU" 조직 단위 이름입니다. |
QSslCertificate::CountryName | 4 | "C" 국가입니다. |
QSslCertificate::StateOrProvinceName | 5 | "ST" 주 또는 시/도입니다. |
QSslCertificate::DistinguishedNameQualifier | 6 | 고유 이름 한정자 |
QSslCertificate::SerialNumber | 7 | 인증서의 일련 번호 |
QSslCertificate::EmailAddress | 8 | 인증서와 연결된 이메일 주소 |
회원 기능 문서
[explicit]
QSslCertificate::QSslCertificate(QIODevice *device, QSsl::EncodingFormat format = QSsl::Pem)
device 에서 format 인코딩된 데이터를 읽고 찾은 첫 번째 인증서를 사용하여 QSslCertificate를 구성합니다. 나중에 isNull()를 호출하여 device 에 인증서가 포함되어 있는지, 그리고 이 인증서가 성공적으로 로드되었는지 확인할 수 있습니다.
[explicit]
QSslCertificate::QSslCertificate(const QByteArray &data = QByteArray(), QSsl::EncodingFormat format = QSsl::Pem)
format 인코딩된 data 을 구문 분석하고 발견된 첫 번째 사용 가능한 인증서를 사용하여 QSslCertificate를 구축합니다. 나중에 isNull()를 호출하여 data 에 인증서가 포함되어 있는지, 그리고 이 인증서가 성공적으로 로드되었는지 확인할 수 있습니다.
QSslCertificate::QSslCertificate(const QSslCertificate &other)
other 의 동일한 복사본을 생성합니다.
[noexcept, since 6.8]
QSslCertificate::QSslCertificate(QSslCertificate &&other)
Move는 other 에서 새 QSslCertificate를 만듭니다.
참고: 이동한 객체 other 는 부분적으로 형성된 상태로 배치되며, 유효한 작업은 파괴와 새 값의 할당뿐입니다.
이 함수는 Qt 6.8에 도입되었습니다.
[noexcept]
QSslCertificate::~QSslCertificate()
QSslCertificate 를 파괴합니다.
void QSslCertificate::clear()
이 인증서의 내용을 지워서 무효 인증서가 됩니다.
isNull()도 참조하세요 .
QByteArray QSslCertificate::digest(QCryptographicHash::Algorithm algorithm = QCryptographicHash::Md5) const
이 인증서의 암호화 다이제스트를 반환합니다. 기본적으로 MD5 다이제스트가 생성되지만 사용자 지정 algorithm 을 지정할 수도 있습니다.
QDateTime QSslCertificate::effectiveDate() const
인증서가 유효하게 되는 날짜와 시간을 반환하거나, 무효 인증서인 경우 빈 QDateTime 을 반환합니다.
expiryDate()도 참조하세요 .
QDateTime QSslCertificate::expiryDate() const
인증서가 만료되는 날짜와 시간을 반환하거나, 무효 인증서인 경우 빈 QDateTime 을 반환합니다.
effectiveDate()도 참조하세요 .
QList<QSslCertificateExtension> QSslCertificate::extensions() const
이 인증서의 X509 확장이 포함된 목록을 반환합니다.
[static]
QList<QSslCertificate> QSslCertificate::fromData(const QByteArray &data, QSsl::EncodingFormat format = QSsl::Pem)
data 에서 지정된 format 으로 인코딩된 모든 인증서를 검색 및 구문 분석하여 인증서 목록으로 반환합니다.
fromDevice()도 참조하세요 .
[static]
QList<QSslCertificate> QSslCertificate::fromDevice(QIODevice *device, QSsl::EncodingFormat format = QSsl::Pem)
device 에서 지정된 format 으로 인코딩된 모든 인증서를 검색 및 구문 분석하여 인증서 목록으로 반환합니다.
fromData()도 참조하세요 .
[static]
QList<QSslCertificate> QSslCertificate::fromPath(const QString &path, QSsl::EncodingFormat format = QSsl::Pem, QSslCertificate::PatternSyntax syntax = PatternSyntax::FixedString)
path 의 모든 파일에서 지정된 format 으로 인코딩된 인증서를 검색하여 목록으로 반환합니다. path 은 syntax 에 지정된 대로 하나 이상의 파일과 일치하는 파일 또는 패턴이어야 합니다.
예:
const auto certs = QSslCertificate::fromPath("C:/ssl/certificate.*.pem", QSsl::Pem, QSslCertificate::와일드카드);for(const QSslCertificate &cert: certs) { qDebug() << cert.issuerInfo(QSslCertificate::Organization);
fromData()도 참조하세요 .
Qt::HANDLE QSslCertificate::handle() const
네이티브 인증서 핸들이 있는 경우 네이티브 인증서 핸들에 대한 포인터를 반환합니다 nullptr
.
이 핸들을 기본 API와 함께 사용하여 인증서에 대한 확장 정보에 액세스할 수 있습니다.
경고: 이 함수를 사용하면 이식성이 없을 가능성이 높으며 반환값은 플랫폼마다 다르거나 마이너 릴리스마다 변경될 수 있습니다.
[static]
bool QSslCertificate::importPkcs12(QIODevice *device, QSslKey *key, QSslCertificate *certificate, QList<QSslCertificate> *caCertificates = nullptr, const QByteArray &passPhrase = QByteArray())
지정된 device 에서 PKCS#12(pfx) 파일을 가져옵니다. PKCS#12 파일은 여러 인증서 및 키를 포함할 수 있는 번들입니다. 이 메서드는 번들에서 단일 key, 해당 certificate 및 연결된 모든 caCertificates 을 읽습니다. passPhrase 을 지정하면 번들을 해독하는 데 사용됩니다. PKCS#12 파일이 성공적으로 로드된 경우 true
를 반환합니다.
참고: device 은 열려 있고 읽을 준비가 되어 있어야 합니다.
bool QSslCertificate::isBlacklisted() const
이 인증서가 블랙리스트에 있으면 true
를 반환하고 그렇지 않으면 false
을 반환합니다.
isNull()도 참조하세요 .
bool QSslCertificate::isNull() const
null 인증서(즉, 내용이 없는 인증서)인 경우 true
를 반환하고 그렇지 않으면 false
을 반환합니다.
기본적으로 QSslCertificate 은 null 인증서를 만듭니다.
clear()도 참조하십시오 .
bool QSslCertificate::isSelfSigned() const
이 인증서가 자체 서명된 경우 true
를 반환하고 그렇지 않으면 false
을 반환합니다.
인증서는 발급자와 주체가 동일하면 자체 서명된 것으로 간주합니다.
QString QSslCertificate::issuerDisplayName() const
발급자를 설명하는 이름을 반환합니다. 사용 가능한 경우 QSslCertificate::CommonName 를 반환하고, 그렇지 않으면 첫 번째 QSslCertificate::Organization 또는 첫 번째 QSslCertificate::OrganizationalUnitName 로 되돌아갑니다.
issuerInfo()도 참조하세요 .
QStringList QSslCertificate::issuerInfo(QSslCertificate::SubjectInfo subject) const
인증서에서 subject 에 대한 발급자 정보를 반환하거나 인증서에 subject 에 대한 정보가 없는 경우 빈 목록을 반환합니다. 각 유형에 대해 하나 이상의 항목이 있을 수 있습니다.
subjectInfo()도 참조하세요 .
QStringList QSslCertificate::issuerInfo(const QByteArray &attribute) const
인증서에서 attribute 에 대한 발급자 정보를 반환하거나 인증서에 attribute 에 대한 정보가 없는 경우 빈 목록을 반환합니다. 속성에 대해 둘 이상의 항목이 있을 수 있습니다.
subjectInfo()도 참조하세요 .
QList<QByteArray> QSslCertificate::issuerInfoAttributes() const
이 인증서의 발급자 정보에 값이 있는 속성 목록을 반환합니다. 지정된 속성과 관련된 정보는 issuerInfo() 메서드를 사용하여 액세스할 수 있습니다. 이 목록에는 SSL 백엔드에서 알 수 없는 모든 요소의 OID가 포함될 수 있습니다.
subjectInfo()도 참조하세요 .
QSslKey QSslCertificate::publicKey() const
인증서 주체의 공개 키를 반환합니다.
QByteArray QSslCertificate::serialNumber() const
인증서의 일련 번호 문자열을 16진수 형식으로 반환합니다.
QMultiMap<QSsl::AlternativeNameEntryType, QString> QSslCertificate::subjectAlternativeNames() const
이 인증서에 대한 대체 주체 이름 목록을 반환합니다. 대체 이름은 일반적으로 이 인증서에 유효한 호스트 이름(선택적으로 와일드카드 포함)을 포함합니다.
이러한 이름은 CommonName 의 주체 정보에 유효한 호스트 이름이 정의되어 있지 않거나 주체 정보 이름이 피어의 호스트 이름과 일치하지 않는 경우 연결된 피어의 호스트 이름과 비교하여 테스트됩니다.
subjectInfo()도 참조하세요 .
QString QSslCertificate::subjectDisplayName() const
주제를 설명하는 이름을 반환합니다. 사용 가능한 경우 QSslCertificate::CommonName 를 반환하고, 그렇지 않으면 첫 번째 QSslCertificate::Organization 또는 첫 번째 QSslCertificate::OrganizationalUnitName 로 되돌아갑니다.
subjectInfo()도 참조하세요 .
QStringList QSslCertificate::subjectInfo(QSslCertificate::SubjectInfo subject) const
subject 에 대한 정보를 반환하거나 인증서에 subject 에 대한 정보가 없는 경우 빈 목록을 반환합니다. 각 유형에 대해 하나 이상의 항목이 있을 수 있습니다.
issuerInfo()도 참조하세요 .
QStringList QSslCertificate::subjectInfo(const QByteArray &attribute) const
attribute 에 대한 주체 정보를 반환하거나 인증서에 attribute 에 대한 정보가 없는 경우 빈 목록을 반환합니다. 속성에 대해 둘 이상의 항목이 있을 수 있습니다.
issuerInfo()도 참조하세요 .
QList<QByteArray> QSslCertificate::subjectInfoAttributes() const
이 인증서의 주체 정보에 값이 있는 속성 목록을 반환합니다. 지정된 속성과 관련된 정보는 subjectInfo() 메서드를 사용하여 액세스할 수 있습니다. 이 목록에는 SSL 백엔드에서 알 수 없는 요소의 OID가 포함될 수 있습니다.
subjectInfo()도 참조하세요 .
[noexcept]
void QSslCertificate::swap(QSslCertificate &other)
이 인증서 인스턴스를 other 로 바꿉니다. 이 작업은 매우 빠르며 실패하지 않습니다.
QByteArray QSslCertificate::toDer() const
이 인증서를 DER(바이너리) 인코딩된 표현으로 변환한 인증서를 반환합니다.
QByteArray QSslCertificate::toPem() const
이 인증서를 PEM(Base64) 인코딩된 표현으로 변환한 인증서를 반환합니다.
QString QSslCertificate::toText() const
이 인증서를 사람이 읽을 수 있는 텍스트 표현으로 변환하여 반환합니다.
[static]
QList<QSslError> QSslCertificate::verify(const QList<QSslCertificate> &certificateChain, const QString &hostName = QString())
인증서 체인을 확인합니다. 확인할 체인은 certificateChain 매개 변수로 전달됩니다. 목록의 첫 번째 인증서는 확인할 체인의 리프 인증서여야 합니다. hostName 을 지정하면 인증서가 지정된 호스트 이름에 유효한지 확인합니다.
루트(CA) 인증서는 확인할 목록에 포함되어서는 안 되며, 기본값 QSslConfiguration 에 지정된 CA 목록을 사용하여 자동으로 조회되며, 가능한 경우 Unix 및 Windows에서 필요에 따라 로드된 CA 인증서도 조회됩니다.
QByteArray QSslCertificate::version() const
인증서의 버전 문자열을 반환합니다.
bool QSslCertificate::operator!=(const QSslCertificate &other) const
이 인증서가 other 과 같지 않으면 true
을 반환하고, 그렇지 않으면 false
을 반환합니다.
QSslCertificate &QSslCertificate::operator=(const QSslCertificate &other)
other 의 내용을 이 인증서에 복사하여 두 인증서를 동일하게 만듭니다.
bool QSslCertificate::operator==(const QSslCertificate &other) const
이 인증서가 other 과 같으면 true
을 반환하고, 그렇지 않으면 false
을 반환합니다.
© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.