1,新建网站,选中类型为
https,然后更改SSL证书为你配置的SSL证书,
对于SSL证书的配置是这样的
点开第二步,然后点击
创建自签名证书
确定以后点开网站看到有个SSL,
双击进去,再选中
要求SSL
选中此步就是为了防止浏览器认为你的网站不安全阻止网站的访问,到此,证书配置完成
然后发现IIS无法绑定域名,因为IIS7默认不支持HTTPS绑定域名,此时需要自己手动去设置
首先打开
C:\Windows\system32\inetsrv\config\applicationHost.config
在里面找到
<bindings>
<binding protocol="https" bindingInformation="*:443" />
<binding protocol="net.tcp" bindingInformation="808:*" />
<binding protocol="net.pipe" bindingInformation="*" />
<binding protocol="net.msmq" bindingInformation="localhost" />
<binding protocol="msmq.formatname" bindingInformation="localhost" />
<binding protocol="http" bindingInformation="*:80:www.console.com" />
</bindings>
找到https的配置项目,修改为:
<binding protocol="https" bindingInformation="*:443:www.console.com" />
这里面需要注意的是:bindings节点有多个,需要找到你配置的站点,默认是<binding protocol="https" bindingInformation="*:443" />
然后保存,此时,HTTPS在IIS7上绑定域名搞定
如下函数回收名字为DefaultAppPool的应用程序池:
Private Sub recycleApplicationPool()
Dim insServerManager As New ServerManager()
insServerManager.ApplicationPools(“DefaultAppPool”).Recycle()
End Sub
函数:
Public Shared Sub createSite(ByVal siteName As String, ByVal dir As String, ByVal domainlist As String)
Try
'insServerManager.Sites.Add("TestSite1", "C:\TestSite", 82)
Dim firstdomain As String = ""
If InStr(domainlist, vbCrLf) > 0 Then
firstdomain = Split(domainlist, vbCrLf)(0)
Else
firstdomain = domainlist
End If
If domainlist = "" Then
MsgBox("请检查域名格式是否正确!")
Exit Sub
End If
ZZform3.DelSite(siteName)
Dim insServerManager As New ServerManager()
Dim mySite As Site = insServerManager.Sites.Add(siteName, "http", "*:80:" & firstdomain, dir)
If firstdomain = "" Or firstdomain = ":80" Then
mySite = insServerManager.Sites.Add(siteName, "http", "*:80", dir)
End If
mySite.ServerAutoStart = True
insServerManager.CommitChanges()
insServerManager.Dispose()
My.Application.DoEvents()
If InStr(domainlist, vbCrLf) > 0 Then
Dim domainarr As Array = Split(domainlist, vbCrLf)
Dim i As Integer = 0
For i = 1 To domainarr.Length - 1
If domainarr(i) = "" Then
Continue For
End If
Dim ServerManager1 As New ServerManager()
Dim mySite1 As Site = ServerManager1.Sites(siteName)
Dim binding1 As Binding = mySite1.Bindings.CreateElement("binding")
Dim bindingsCollection1 As ConfigurationElementCollection = mySite1.GetCollection("bindings")
binding1("protocol") = "http"
binding1("bindingInformation") = "*:80:" & domainarr(i)
bindingsCollection1.Add(binding1)
ServerManager1.CommitChanges()
ServerManager1.Dispose()
My.Application.DoEvents()
Next
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
如对本文有疑问,请提交到交流论坛,广大热心网友会为你解答!! 点击进入论坛