Thanks Mounir for your reply. I have done using this way only. Its
working fine.
Post by anupama joshiHi,
I want to add the certificate which is trusted and may be self signed or from CA but needs to be used as a trusted root. When I open in-memory store using certOpenStore and add the cert there I get error in handshake.
If I use System store "Root" and I add it to the Root store it works fine, but then it shows the dialog which I do not want . Also then the cert remains in the store.
I want memory store but the cert should be treated as trusted. What Can I do?
Thanks
_Anupama
HEre is my code
if(hMemStore == NULL){
hMemStore = CertOpenStore(
CERT_STORE_PROV_MEMORY, // The memory provider type
0, // The encoding type is not needed
NULL, // Use the default HCRYPTPROV
0, // Accept the default dwFlags
NULL // pvPara is not used
);
}
if(hMemStore)
{
PLAYEROUTPUT(("The memory store was created successfully.\n"));
for(U32 i=0; i<certs->size(); i++){
BYTE *buf = certs->get(i);
U32 len = lenArr->get(i);
m_trustedCertificateBytes = buf;
m_isCertTrustedAnchor = isTrustedArr->get(i);
m_trustedCertificateLen = len;
/*CertCreateContext
CertCreateCTLEntryFromCertificateContextProperties
*/
if(CertAddEncodedCertificateToStore(
hMemStore,
CERT_ENCODING_TYPE,
m_trustedCertificateBytes,
m_trustedCertificateLen,
CERT_STORE_ADD_USE_EXISTING,
NULL))
{
PLAYEROUTPUT(("Another certificate is added to the file store.\n"));
}
else{
PLAYEROUTPUT(("CertAddEncodedCertificateToStore failed with error code 0x%x.\n", ::GetLastError()));
}
}
}
Post by anupama joshiHi,
I want to add the certificate which is trusted and may be self signed or from CA but needs to be used as a trusted root. When I open in-memory store using certOpenStore and add the cert there I get error in handshake.
If I use System store "Root" and I add it to the Root store it works fine, but then it shows the dialog which I do not want . Also then the cert remains in the store.
I want memory store but the cert should be treated as trusted. What Can I do?
Thanks
_Anupama
HEre is my code
if(hMemStore == NULL){
hMemStore = CertOpenStore(
CERT_STORE_PROV_MEMORY, // The memory provider type
0, // The encoding type is not needed
NULL, // Use the default HCRYPTPROV
0, // Accept the default dwFlags
NULL // pvPara is not used
);
}
if(hMemStore)
{
PLAYEROUTPUT(("The memory store was created successfully.\n"));
for(U32 i=0; i<certs->size(); i++){
BYTE *buf = certs->get(i);
U32 len = lenArr->get(i);
m_trustedCertificateBytes = buf;
m_isCertTrustedAnchor = isTrustedArr->get(i);
m_trustedCertificateLen = len;
/*CertCreateContext
CertCreateCTLEntryFromCertificateContextProperties
*/
if(CertAddEncodedCertificateToStore(
hMemStore,
CERT_ENCODING_TYPE,
m_trustedCertificateBytes,
m_trustedCertificateLen,
CERT_STORE_ADD_USE_EXISTING,
NULL))
{
PLAYEROUTPUT(("Another certificate is added to the file store.\n"));
}
else{
PLAYEROUTPUT(("CertAddEncodedCertificateToStore failed with error code 0x%x.\n", ::GetLastError()));
}
}
}
Submitted via EggHeadCafe - Software Developer Portal of Choice
FireAndForget Asynchronous Utility Class for SQL Server Inserts and Updates
http://www.eggheadcafe.com/tutorials/aspnet/7a22d9a4-59fc-40b0-8337-75c76f14fb3b/fireandforget-asynchronous-utility-class-for-sql-server-inserts-and-updates.aspx