Note that there are some explanatory texts on larger screens.

plurals
  1. POIIS 8 - Not finding default.html when using SSL certificate
    primarykey
    data
    text
    <p>I've created a webapp and a console application to register the website in the IIS. There seems to be no problem there at all.</p> <p>This is the code I use for registering the website in the IIS.</p> <pre><code>Dim manager As New ServerManager Dim site As Site = manager.Sites.Add("MyControl", "http", "*:80:test.localhost", "C:\\inetpub\wwwroot\MyControl") manager.ApplicationPools.Add("MyControl") site.ApplicationDefaults.ApplicationPoolName = "MyControl" manager.CommitChanges() </code></pre> <p>The site is registered fine in the IIS. Type being http, hostname being test.localhost, port being 80 and the ip being *. Like expected.</p> <p>I've modified my hosts file, added the line: <code>127.0.0.1 test.localhost</code> so that navigating to <a href="http://test.localhost" rel="nofollow noreferrer">http://test.localhost</a> will resolve in a redirect to our site on the IIS.</p> <p>This should mean redirecting to our default page default.html which is in the root of inetpub/wwwroot/MyControl.</p> <p>This doesn't happen however. I get a blank page and no title and the source is blank, but not a page not found. Furthermore, if I navigate to <a href="http://test.localhost/default.html" rel="nofollow noreferrer">http://test.localhost/default.html</a> myself, I get a blank page, but a title saying: MyControl. And if I now take a look at the source, I can see that it finds the file, but nothing is displayed.</p> <p>If I set up the website in the IIS manually, there's no problem.</p> <p>Any ideas would be appreciated.</p> <p>EDIT:</p> <p>So far, so good. I've now made it work with the above code. What happened you ask? I have no clue.</p> <p>Now I need to use the same website, but install it with an SSL-certificate.</p> <p>I'm using this code</p> <pre><code>Module Main &lt;DllImport("advapi32.DLL", SetLastError:=True)&gt; Public Function LogonUser(ByVal username As String, ByVal domain As String, ByVal password As String, ByVal logonType As Integer, ByVal logonProvider As Integer, ByRef token As IntPtr) As Integer End Function Sub Main() 'Load indstillinger fra app.config Dim sslPath As String = ConfigurationManager.AppSettings("sslPath") Dim sslPassword As String = ConfigurationManager.AppSettings("sslPassword") Dim remoteUsername As String = ConfigurationManager.AppSettings("remoteUsername") Dim remotePassword As String = ConfigurationManager.AppSettings("remotePassword") 'Lav en store, således at vi kan få fat i vores ssl certifikat Dim store As X509Store = New X509Store(StoreName.My, StoreLocation.LocalMachine) store.Open(OpenFlags.OpenExistingOnly Or OpenFlags.ReadWrite) 'Generer credentials til impersonation Dim adminToken As IntPtr = IntPtr.Zero Dim admin As WindowsIdentity = Nothing Dim context As WindowsImpersonationContext = Nothing 'Login med den specificerede bruger LogonUser(remoteUsername, System.Environment.MachineName, remotePassword, 9, 0, adminToken) '9 afspejler logintype og 0 afspejler loginprovider - Ingen idé om hvad det har af betydning admin = New WindowsIdentity(adminToken) context = admin.Impersonate() 'Import af SSL certifikat Dim certificate As X509Certificate2 = New X509Certificate2(sslPath, sslPassword) 'Sti til SSL certifikat og password til at installere dette store.Add(certificate) 'Opret en manager og en config til oprettelse af site Dim manager As New ServerManager Dim config As Microsoft.Web.Administration.Configuration = manager.GetApplicationHostConfiguration() 'Opret site i IIS med det valgte certifikat Dim site As Site = manager.Sites.Add("MyControl", "*:443:webmail.jcdhotel.dk", "C:\\inetpub\wwwroot\MyControl", certificate.GetCertHash()) 'Kræv SSL Dim accessSection As Microsoft.Web.Administration.ConfigurationSection = config.GetSection("system.webServer/security/access", "MyControl") accessSection("sslFlags") = "Ssl" 'Opret en applicationpool specifikt til MyControl og sæt denne til default manager.ApplicationPools.Add("MyControl") site.ApplicationDefaults.ApplicationPoolName = "MyControl" 'Luk store store.Close() 'Gem ændringer og revert impersonation manager.CommitChanges() context.Undo() End Sub </code></pre> <p>Again. The code is registering the website in the IIS and sets the certificate just fine. The binding looks like this</p> <p><img src="https://i.stack.imgur.com/cYNIv.jpg" alt="Error"></p> <p>I have again modified my hosts file, adding the line <code>127.0.0.1 webmail.jcdhotel.dk</code></p> <p>I can go to the link <a href="https://webmail.jcdhotel.dk" rel="nofollow noreferrer">https://webmail.jcdhotel.dk</a> and recieve a blank page and the source being blank. I can then go to <a href="https://webmail.jcdhotel.dk/default.html" rel="nofollow noreferrer">https://webmail.jcdhotel.dk/default.html</a> and the title will be set and I can now check the source but the page is still blank.</p> <p>Again, any help is appreciated and thank you in advance!</p> <p>EDIT:</p> <p>New information. By manually trying to add the website to IIS with the SSL certificate, I recieve the following error:</p> <p><img src="https://i.stack.imgur.com/Jo0sp.jpg" alt="SSL Error"></p> <p>Hopefully this will help shed some light on the problem.</p> <p>EDIT:</p> <p>Last edit, hopefully :D</p> <p>I can now manually add a binding using the SSL certificate. The problem was due to the certificate being installed incorrectly. Which leads me to the final hurdle.</p> <p>When adding the certificate to the store using vb.net. How do I check the "Allow certificate to be exported"? - Since that solved my problem when adding the certificate manually.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload