Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
c2784340
Commit
c2784340
authored
Jun 20, 2011
by
Brad Fitzpatrick
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
http: add Server.ListenAndServeTLS
Fixes #1964 R=rsc CC=golang-dev
https://golang.org/cl/4630045
parent
10f1436b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
2 deletions
+22
-2
src/pkg/http/server.go
src/pkg/http/server.go
+22
-2
No files found.
src/pkg/http/server.go
View file @
c2784340
...
...
@@ -908,7 +908,9 @@ func ListenAndServe(addr string, handler Handler) os.Error {
// ListenAndServeTLS acts identically to ListenAndServe, except that it
// expects HTTPS connections. Additionally, files containing a certificate and
// matching private key for the server must be provided.
// matching private key for the server must be provided. If the certificate
// is signed by a certificate authority, the certFile should be the concatenation
// of the server's certificate followed by the CA's certificate.
//
// A trivial example server is:
//
...
...
@@ -933,6 +935,24 @@ func ListenAndServe(addr string, handler Handler) os.Error {
//
// One can use generate_cert.go in crypto/tls to generate cert.pem and key.pem.
func
ListenAndServeTLS
(
addr
string
,
certFile
string
,
keyFile
string
,
handler
Handler
)
os
.
Error
{
server
:=
&
Server
{
Addr
:
addr
,
Handler
:
handler
}
return
server
.
ListenAndServeTLS
(
certFile
,
keyFile
)
}
// ListenAndServeTLS listens on the TCP network address srv.Addr and
// then calls Serve to handle requests on incoming TLS connections.
//
// Filenames containing a certificate and matching private key for
// the server must be provided. If the certificate is signed by a
// certificate authority, the certFile should be the concatenation
// of the server's certificate followed by the CA's certificate.
//
// If srv.Addr is blank, ":https" is used.
func
(
s
*
Server
)
ListenAndServeTLS
(
certFile
,
keyFile
string
)
os
.
Error
{
addr
:=
s
.
Addr
if
addr
==
""
{
addr
=
":https"
}
config
:=
&
tls
.
Config
{
Rand
:
rand
.
Reader
,
Time
:
time
.
Seconds
,
...
...
@@ -952,7 +972,7 @@ func ListenAndServeTLS(addr string, certFile string, keyFile string, handler Han
}
tlsListener
:=
tls
.
NewListener
(
conn
,
config
)
return
Serve
(
tlsListener
,
handl
er
)
return
s
.
Serve
(
tlsListen
er
)
}
// TimeoutHandler returns a Handler that runs h with the given time limit.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment