Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 15 additions & 16 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ package main

import (
"context"
"crypto/tls"
"flag"
"fmt"
"net/http"
"os"
"os/signal"
"syscall"
"time"
"crypto/tls"

"github.com/caarlos0/env"
"github.com/jpweber/cole/configuration"
Expand Down Expand Up @@ -95,19 +95,19 @@ func main() {
// Server Lifecycle
//To setup a insecure server for http without any tls validation
/*
s := &http.Server{
Addr: ":8080",
ReadTimeout: 5 * time.Second,
WriteTimeout: 10 * time.Second,
}
go func() {
log.Fatal(s.ListenAndServe())
}()
s := &http.Server{
Addr: ":8080",
ReadTimeout: 5 * time.Second,
WriteTimeout: 10 * time.Second,
}
go func() {
log.Fatal(s.ListenAndServe())
}()
*/

//To setup a https secure server with certificate validation.
//To setup a https secure server with TLS 1.2
cfg := &tls.Config{
//To setup a https secure server with TLS 1.2
cfg := &tls.Config{
MinVersion: tls.VersionTLS12,
PreferServerCipherSuites: true,
CipherSuites: []uint16{
Expand All @@ -118,17 +118,16 @@ func main() {
},
}


s := &http.Server{
ReadTimeout: 5 * time.Second,
WriteTimeout: 10 * time.Second,
TLSConfig: cfg,
}
#err := http.ListenAndServeTLS(":443", "/usr/local/share/ca-certificates/https-server.crt", "/usr/local/share/ca-certificates/https-server.key", nil);
err := s.ListenAndServeTLS("/usr/local/share/ca-certificates/https-server.crt", "/usr/local/share/ca-certificates/https-server.key");
err := s.ListenAndServeTLS("/usr/local/share/ca-certificates/https-server.crt", "/usr/local/share/ca-certificates/https-server.key")

if err != nil {
log.Fatal(err)
}
log.Fatal(err)
}

signalChan := make(chan os.Signal, 1)
signal.Notify(signalChan, syscall.SIGINT, syscall.SIGTERM)
Expand Down