/// <summary> /// Creates the application. /// </summary> /// /// <remarks> /// The caller should store the value of the ApplicationId property so it can re-use this /// application. This method will lookup the certificate by application Id. If no /// certificate is found, it creates one in the current user store. /// </remarks> /// /// <exception ref="CryptographicException"> /// If the certificate cannot be created or could not be added to the store. /// </exception> /// /// private void CreateApplication() { // If no child certificate exists, create a new ApplicationCertificate // ApplicationCertificate will find the certificate name HVClient-appId // in the local user store. If one does not exist, a new certificate will be created if (_childCert == null) { _childCert = new ApplicationCertificate(_applicationId); } }
/// <summary> /// Deletes the certificate created as part of application creation /// </summary> /// /// <exception cref="InvalidConfigurationException"> /// The required application-specific certificate is not found, /// </exception> /// public void DeleteCertificate() { if (_childCert == null) { throw Validator.InvalidConfigurationException("InvalidApplicationCertificate"); } using (CertificateStore store = new CertificateStore(StoreLocation.CurrentUser)) { store.RemoveCert(_childCert.Certificate); _childCert.Dispose(); _childCert = null; } ApplicationCertificate.DeleteKeyContainer(_applicationId); }