Symbian Developer Network

   
 

Need help using the forums?
Click here

Home » Symbian Developer Network Forums » Discussion Groups » Connectivity

Thread: CSecureSocket, port 443 and trusted certificates

Legend
  • Five stars: 251 - 10000 pts
  • Four stars: 101 - 250 pts
  • Three stars: 51 - 100 pts
  • Two stars: 11 - 50 pts
  • One star: 1 - 10 pts
  • No stars: 0 - 0 pts
Helpful Answer (1 pts)
Correct Answer (2 pts)
This question is answered.


Permlink Replies: 19 - Pages: 2 [ Previous | 1 2 ] - Last Post: 22-Jun-2009 05:44 Last Post By: ivey Threads: [ Previous | Next ]
ivey

Posts: 78
Registered: 18/10/06
Re: CSecureSocket, port 443 and trusted certificates
Posted: 19-Jun-2009 07:52   in response to: mach in response to: mach
 
Click to report abuse...   Click to reply to this thread Reply
I am very glad it works now!

Good luck!
ivey
mach

Posts: 71
Registered: 26/05/08
Re: CSecureSocket, port 443 and trusted certificates
Posted: 19-Jun-2009 11:45   in response to: ivey in response to: ivey
 
Click to report abuse...   Click to reply to this thread Reply
Well, I added it correctly to the certificate store on the phone now, but still, the application would ask me to confirm whether I trusted the certificate. So, I edited by hand in Tools->Settings->General->Security->Cert. Mngment the "Trust Settings" for this certificate (Internet: yes, Online certif. check: no, VPN: yes). And now, it doesn´t prompt me anymore. So, again, many thanks.

Still,for curiosity´s sake: I have tried looking around for a way to set the certificate to trusted by software and run into the method CUnifiedCertStore::SetTrust. Unfortunately, this takes a CCTCertInfo object as an argument (instead of CCertificate) so it seems I am back to the whole rigmarole of writing to writestreams and reading from readstreams just to convert a Certificate to a CCTCertInfo. Why isn´t there a way to initialize a CCTCertInfo with a HBufC8? The only two constructors I see are either taking a RReadStream object or by means of passing a number of fields, some of which I cannot extract from CCertificate.

I tried the following (code below), but that would crash at the moment of calling "CCTCertInfo::NewL(readStream, token)".

code

HBufC8* aCertData = HBufC8::NewL(aCertificate.Encoding().Size());

aCertData->Des().Copy(aCertificate.Encoding());


MCTToken& token = iWritableStore->Token();


RBufWriteStream writeStream;

CBufFlat* bufflat = CBufFlat::NewL(2048);

writeStream.Open(*bufflat, 0);

aCertificate.ExternalizeL(writeStream);


RBufReadStream readStream(*bufflat);

CCTCertInfo* aCertInfo = CCTCertInfo::NewL(readStream, token);

TCertificateFormat certFormat = aCertInfo->CertificateFormat();


iCertStore->Retrieve(*aCertInfo, iRetrieveCertificate, iStatus);

[/code]

ivey

Posts: 78
Registered: 18/10/06
Re: CSecureSocket, port 443 and trusted certificates
Posted: 19-Jun-2009 12:00   in response to: mach in response to: mach
 
Click to report abuse...   Click to reply to this thread Reply
The trick is that you do not need to create a CCTCertInfo object. You need to find the certificate that you have just installed via CUnifiedCertStore::List() method that returns an array of CCTCertInfo objects. This array should contain CCTCertInfo of your certificate. After finding you certificate you need to call CUnifiedCertStore::SetTrust() and then CUnifiedCertStore::SetApplicability() methods to make your certificate trusted. As I understand your requirements you need to use KTlsApplicabilityUid in CUnifiedCertStore::SetApplicability().
mach

Posts: 71
Registered: 26/05/08
Re: CSecureSocket, port 443 and trusted certificates
Posted: 20-Jun-2009 17:36   in response to: ivey in response to: ivey
 
Click to report abuse...   Click to reply to this thread Reply
Again, you are absolutely right. Perfect!
Now, I really don´t have any questions anymore. :)

Well, maybe one: how do you know all this? Because with just the documentation available, I never would have gotten all this.
Anyway, many thanks because you really helped me out here.
ivey

Posts: 78
Registered: 18/10/06
Re: CSecureSocket, port 443 and trusted certificates
Posted: 22-Jun-2009 05:44   in response to: mach in response to: mach
 
Click to report abuse...   Click to reply to this thread Reply
Hi,

when I needed to implement similar functionality I spent a lot of time on it and with trial and error I finally got it working :)

Glad that I could help you.

Regards,
ivey

Point your RSS reader here for a feed of the latest messages in all forums