Ejemplo n.º 1
0
 public void CreateSigningRequest ()
 {
     var dto = new CertRequestDTO ();
     CreateCertificateWindowController cwc = new CreateCertificateWindowController (dto);
     NSApplication.SharedApplication.BeginSheet (cwc.Window, VMCAAppEnvironment.Instance.MainWindow, () => {
     });
     try {
         nint result = NSApplication.SharedApplication.RunModalForWindow (cwc.Window);
         if (result == (nint)Constants.DIALOGOK) {
             using (var request = new VMCARequest (this.ServerDTO.VMCAClient)) {
                 dto.FillRequest (request);
                 string csr = request.GetCSR (dto.PrivateKey.ToString ());
                 this.ServerDTO.SigningRequests.Add (new SigningRequestDTO {
                     CreatedDateTime = DateTime.Now,
                     CSR = csr
                 });
                 GenericTextViewWindowController gwc = new GenericTextViewWindowController (csr);
                 gwc.Window.Title = "CSR Data";
                 NSApplication.SharedApplication.RunModalForWindow (gwc.Window);
                 NSNotificationCenter.DefaultCenter.PostNotificationName ("ReloadTableView", this);
             }
         }
     } catch (Exception e) {
         UIErrorHelper.ShowAlert (e.Message, "Operation could not complete successfully.");
     } finally {
         VMCAAppEnvironment.Instance.MainWindow.EndSheet (cwc.Window);
         cwc.Dispose ();
     }
 }
        public void CreateSelfSignedCertificate ()
        {
            var dto = new CertRequestDTO ();
            CreateCertificateWindowController cwc = new CreateCertificateWindowController (dto);
            NSApplication.SharedApplication.BeginSheet (cwc.Window, VMCAAppEnvironment.Instance.MainWindow, () => {
            });
            try {
                nint result = NSApplication.SharedApplication.RunModalForWindow (cwc.Window);
                if (result == (nint)Constants.DIALOGOK) {
                    using (var request = new VMCARequest (this.ServerDTO.VMCAClient)) {
                        dto.FillRequest (request);
                        var vmcaCert = request.GetSelfSignedCertificate (dto.PrivateKey.ToString (), dto.NotBefore, dto.NotAfter);
                        var cert = vmcaCert.GetX509Certificate2 ();

                        var localCertDTO = new PrivateCertificateDTO {
                            Certificate = Convert.ToBase64String (cert.RawData)
                        };
                        UIErrorHelper.ShowAlert ("", "Successfully Created A Self Signed Certificate");
                        this.ServerDTO.PrivateCertificates.Add (localCertDTO);
                        NSNotificationCenter.DefaultCenter.PostNotificationName ("ReloadTableView", this);
                        CertificateService.DisplayX509Certificate2 (this, cert);
                    }
                }
            } catch (Exception e) {
                UIErrorHelper.ShowAlert (e.Message, "Operation could not complete successfully.");
            } finally {
                VMCAAppEnvironment.Instance.MainWindow.EndSheet (cwc.Window);
                cwc.Dispose ();
            }
        }
Ejemplo n.º 3
0
 public void FillRequest (VMCARequest request)
 {
     request.Country = Country;
     request.DNSName = DNSName;
     request.Email = Email;
     request.IPAddress = IPAddress;
     request.KeyUsageConstraints = KeyUsageConstraints;
     request.Locality = Locality;
     request.Name = Name;
     request.Organization = Organization;
     request.OU = OU;
     request.State = State;
     request.URIName = URIName;
 }