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 ();
            }
        }
Пример #2
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 ();
     }
 }
 // Call to load from the XIB/NIB file
 public CreateCertificateWindowController (CertRequestDTO dto) : base ("CreateCertificateWindow")
 {
     this.dto = dto;
 }