@@ -26,6 +26,7 @@ namespace nvQuickSite
26
26
using System . IO ;
27
27
using System . Linq ;
28
28
using System . Net ;
29
+ using System . Security . Cryptography . X509Certificates ;
29
30
using System . Windows . Forms ;
30
31
31
32
using Ionic . Zip ;
@@ -52,6 +53,7 @@ public partial class Start : MetroUserControl
52
53
private long total ;
53
54
private long lastVal ;
54
55
private long sum ;
56
+ private List < X509Certificate2 > certificates ;
55
57
56
58
/// <summary>
57
59
/// Initializes a new instance of the <see cref="Start"/> class.
@@ -128,6 +130,12 @@ private void ReadUserSettings()
128
130
this . txtSiteNameSuffix . Text = Properties . Settings . Default . SiteNameSuffixRecent ;
129
131
this . chkSiteSpecificAppPool . Checked = Properties . Settings . Default . AppPoolRecent ;
130
132
this . chkDeleteSiteIfExists . Checked = Properties . Settings . Default . DeleteSiteInIISRecent ;
133
+ this . chkEnableSsl . Checked = Properties . Settings . Default . EnableSsl ;
134
+ if ( Properties . Settings . Default . CertificateFriendlyName != string . Empty )
135
+ {
136
+ this . cboCertificates . SelectedItem = Properties . Settings . Default . CertificateFriendlyName ;
137
+ }
138
+
131
139
this . txtInstallBaseFolder . Text = Properties . Settings . Default . InstallBaseFolderRecent ;
132
140
133
141
this . txtDBServerName . Text = Properties . Settings . Default . DatabaseServerNameRecent ;
@@ -144,6 +152,12 @@ private void SaveUserSettings()
144
152
Properties . Settings . Default . SiteNameSuffixRecent = this . txtSiteNameSuffix . Text ;
145
153
Properties . Settings . Default . AppPoolRecent = this . chkSiteSpecificAppPool . Checked ;
146
154
Properties . Settings . Default . DeleteSiteInIISRecent = this . chkDeleteSiteIfExists . Checked ;
155
+ Properties . Settings . Default . EnableSsl = this . chkEnableSsl . Checked ;
156
+ if ( this . cboCertificates . SelectedItem != null )
157
+ {
158
+ Properties . Settings . Default . CertificateFriendlyName = this . cboCertificates . SelectedItem . ToString ( ) ;
159
+ }
160
+
147
161
Properties . Settings . Default . InstallBaseFolderRecent = this . txtInstallBaseFolder . Text ;
148
162
149
163
Properties . Settings . Default . DatabaseServerNameRecent = this . txtDBServerName . Text ;
@@ -412,6 +426,31 @@ private void txtSiteNamePrefix_TextChanged(object sender, EventArgs e)
412
426
this . txtDBName . Text = this . txtSiteNamePrefix . Text ;
413
427
}
414
428
429
+ private void chkEnableSsl_CheckedChanged ( object sender , EventArgs e )
430
+ {
431
+ this . cboCertificates . Visible = false ;
432
+ if ( this . chkEnableSsl . Checked )
433
+ {
434
+ this . LoadSslCertificates ( ) ;
435
+ this . cboCertificates . Visible = true ;
436
+ }
437
+ }
438
+
439
+ private void LoadSslCertificates ( )
440
+ {
441
+ this . cboCertificates . Items . Clear ( ) ;
442
+ this . certificates = IISController . GetSslCertificates ( ) ;
443
+ this . certificates . ForEach ( c => this . cboCertificates . Items . Add ( c . FriendlyName != string . Empty ? c . FriendlyName : c . Subject . Split ( ',' ) [ 0 ] . Split ( '=' ) [ 1 ] ) ) ;
444
+ if ( this . cboCertificates . Items . Count > 0 )
445
+ {
446
+ this . cboCertificates . SelectedIndex = 0 ;
447
+ if ( Properties . Settings . Default . CertificateFriendlyName != string . Empty )
448
+ {
449
+ this . cboCertificates . SelectedItem = Properties . Settings . Default . CertificateFriendlyName ;
450
+ }
451
+ }
452
+ }
453
+
415
454
private void btnSiteInfoNext_Click ( object sender , EventArgs e )
416
455
{
417
456
bool proceed ;
@@ -549,7 +588,8 @@ private void btnDatabaseInfoNext_Click(object sender, EventArgs e)
549
588
this . SiteName ,
550
589
this . InstallFolder ,
551
590
this . chkSiteSpecificAppPool . Checked ,
552
- this . chkDeleteSiteIfExists . Checked ) ;
591
+ this . chkDeleteSiteIfExists . Checked ,
592
+ this . certificates [ this . cboCertificates . SelectedIndex ] ) ;
553
593
554
594
FileSystemController . UpdateHostsFile ( this . SiteName ) ;
555
595
@@ -668,7 +708,8 @@ private void myZip_ExtractProgress(object sender, ExtractProgressEventArgs e)
668
708
669
709
private void btnVisitSite_Click ( object sender , EventArgs e )
670
710
{
671
- var url = "http://" + this . SiteName ;
711
+ var protocol = this . chkEnableSsl . Checked ? "https://" : "http://" ;
712
+ var url = protocol + this . SiteName ;
672
713
Log . Logger . Information ( "Visiting {url}" , url ) ;
673
714
Process . Start ( url ) ;
674
715
Log . Logger . Information ( "Closing application" ) ;
0 commit comments