diff --git a/config/configuration.go b/config/configuration.go
index 099d9920d36a96f707af4b4ad038dc2eb81139be..1dc64cc9b2871ae7c35abbead49c45a91a4ab447 100644
--- a/config/configuration.go
+++ b/config/configuration.go
@@ -1,5 +1,10 @@
 package config
 
+import (
+	"github.com/spf13/viper"
+	"log"
+)
+
 type Configuration struct {
 	Server ServerConfig
 	OpenId OpenIDConfig
@@ -34,3 +39,29 @@ type RDGCapsConfig struct {
 	DisablePnp       bool
 	DisableDrive     bool
 }
+
+func init() {
+	viper.SetDefault("server.certFile", "server.pem")
+	viper.SetDefault("server.keyFile", "key.pem")
+	viper.SetDefault("server.port", 443)
+}
+
+func Load(configFile string) Configuration {
+	var conf Configuration
+
+	viper.SetConfigName("rdpgw")
+	viper.SetConfigFile(configFile)
+	viper.AddConfigPath(".")
+	viper.SetEnvPrefix("RDPGW")
+	viper.AutomaticEnv()
+
+	if err := viper.ReadInConfig(); err != nil {
+		log.Printf("No config file found (%s). Using defaults", err)
+	}
+
+	if err := viper.Unmarshal(&conf); err != nil {
+		log.Fatalf("Cannot unmarshal the config file; %s", err)
+	}
+
+	return conf
+}
\ No newline at end of file
diff --git a/main.go b/main.go
index 5e854b13e98d471fe55e9bcbf7c18bcc9206f666..e5d9960f3242e5255ceb168881a6a16a560d7ea3 100644
--- a/main.go
+++ b/main.go
@@ -9,7 +9,6 @@ import (
 	"github.com/prometheus/client_golang/prometheus"
 	"github.com/prometheus/client_golang/prometheus/promhttp"
 	"github.com/spf13/cobra"
-	"github.com/spf13/viper"
 	"golang.org/x/oauth2"
 	"log"
 	"net/http"
@@ -37,20 +36,7 @@ var ctx context.Context
 func main() {
 	// get config
 	cmd.PersistentFlags().StringVarP(&configFile, "conf", "c", "rdpgw.yaml",  "config file (json, yaml, ini)")
-
-	viper.SetConfigName("rdpgw")
-	viper.SetConfigFile(configFile)
-	viper.AddConfigPath(".")
-	viper.SetEnvPrefix("RDPGW")
-	viper.AutomaticEnv()
-
-	if err := viper.ReadInConfig(); err != nil {
-		log.Printf("No config file found (%s). Using defaults", err)
-	}
-
-	if err := viper.Unmarshal(&conf); err != nil {
-		log.Fatalf("Cannot unmarshal the config file; %s", err)
-	}
+	conf = config.Load(configFile)
 
 	// set oidc config
 	ctx = context.Background()