Windows Mobile Sample Code

This sample code illustrates importing the certificate and setting up login credentials, as well as other APIs related to certificate handling:

/// End2EndDB is a generated RBS class
///First install certificates on your emulator, for example "Sybase101.p12"

//Test getting certificate from certificate store 
CertificateStore myStore = CertificateStore.GetDefault();                     
string filter1 = "Sybase";
StringList labels = myStore.CertificateLabels(filter1, null);        
string aLabel = labels.Item(0);
LoginCertificate lc = myStore.GetSignedCertificate(aLabel, "password");

// Save the login certificate to your synchronization profile
End2EndDB.GetSynchronizationProfile().Certificate = lc;

// Login to Unwired Server without username/password
End2EndDB.LoginToSync();           

//Perform synchronization
End2EndDB.Synchronize();

// Save the login certificate to your data vault
DataVault vault = null;
if (!DataVault.VaultExists("myVault"))
{
    vault = DataVault.CreateVault("myVault", "password", "salt");
}
else
{
    vault = DataVault.GetVault("myVault");
}
vault.Unlock("password", "salt");
lc.Save("myLabel", vault);

// Get certificate that was previously loaded from the data vault 
LoginCertificate newLc = LoginCertificate.Load("myLabel", vault);
Debug.Assert(newLc.SubjectDN.Equals(lc.SubjectDN));

// Delete the certificate from the data vault
LoginCertificate.Delete("myLabel", vault);