32 #include <tdetempfile.h>
38 KSSLPKCS7::KSSLPKCS7() {
41 kossl = KOSSL::self();
48 if (_pkcs) kossl->PKCS7_free(_pkcs);
50 if (_cert)
delete _cert;
58 if (base64.isEmpty())
return NULL;
59 TQByteArray qba, qbb = TQCString(base64.latin1()).copy();
60 KCodecs::base64Decode(qbb, qba);
61 ktf.file()->writeBlock(qba);
75 PKCS7 *newpkcs = NULL;
77 if (!qf.open(IO_ReadOnly))
80 FILE *fp = fdopen(qf.handle(),
"r");
83 newpkcs = KOSSL::self()->d2i_PKCS7_fp(fp, &newpkcs);
85 if (!newpkcs)
return NULL;
122 len = kossl->i2d_PKCS7(_pkcs, NULL);
124 char *buf =
new char[len];
125 p = (
unsigned char *)buf;
126 kossl->i2d_PKCS7(_pkcs, &p);
128 qba.setRawData(buf, len);
129 base64 = KCodecs::base64Encode(qba);
130 qba.resetRawData(buf, len);
141 TQFile out(filename);
143 if (!out.open(IO_WriteOnly))
return false;
145 int fd = out.handle();
146 FILE *fp = fdopen(fd,
"w");
149 unlink(filename.latin1());
153 kossl->i2d_PKCS7_fp(fp, _pkcs);
167 return KSSLCertificate::NoSSL;
175 return KSSLCertificate::Unknown;
180 return (
validate() == KSSLCertificate::Ok);
KDE Certificate Chain Representation Class.
KSSLValidation
A CA certificate can be validated as Irrelevant when it was not used to sign any other relevant certi...
KSSLValidation revalidate()
Check if this is a valid certificate.
TQString getSubject() const
Get the subject of the certificate (X.509 map).
KSSLValidation validate()
Check if this is a valid certificate.
void setCert(PKCS7 *c)
Raw set the PKCS7 object.
KSSLCertificate::KSSLValidation validate()
Check the chain to make sure it's valid.
static KSSLPKCS7 * fromString(TQString base64)
Create a KSSLPKCS7 object from a Base64 in a TQString.
bool toFile(TQString filename)
Write the PKCS#7 to a file in raw mode.
KSSLCertChain * getChain()
Get the certificate chain.
bool isValid()
Return true if the chain is valid.
TQString toString()
Convert to a Base64 string.
TQString name()
The name of this certificate.
KSSLCertificate * getCertificate()
Get the bottom level X.509 certificate.
static KSSLPKCS7 * loadCertFile(TQString filename)
Create a KSSLPKCS7 object by reading a PKCS#7 file.
virtual ~KSSLPKCS7()
Destroy this PKCS#7 certificate.
KSSLCertificate::KSSLValidation revalidate()
Check the chain to make sure it's valid.