SSL Configuration


#1

Hello all!!

I have gotten my application to work with the StartAutoTLS configuration, but I would like it to use my own Certificates. Here is a snippet of my code that is doing the serving:

go func() {
	if Util.Getenv("SECURE", "NO") == "YES" {
		if Util.Getenv("CERTFILE", "") != "" {
			if _, err := os.Stat(Util.Getenv("CERTFILE", "")); err == nil {
				if Util.Getenv("KEYFILE", "") != "" {
					if _, err := os.Stat(Util.Getenv("KEYFILE", "")); err == nil {
						// Holy crap, we can start the server!!
						if err := e.StartTLS(":443", Util.Getenv("CERTFILE", ""), Util.Getenv("KEYFILE", "")); err != nil {
							e.Logger.Info("Shutting down server...")
						}
					} else if os.IsNotExist(err) {
						// KEYFILE doesn't exist
						e.Logger.Fatal("KEYFILE does not exist")
					}
				} else {
					// KEYFILE not supplied
					e.Logger.Fatal("KEYFILE not supplied in environment file")
				}
			} else if os.IsNotExist(err) {
				// CERTFILE doesn't exist
				e.Logger.Fatal("CERTFILE does not exist")
			}
		} else {
			// CERTFILE not supplied
			e.Logger.Fatal("CERTFILE not supplied in environment file")
		}
	} else {
		if err := e.Start(":" + Util.Getenv("PORT", "80")); err != nil {
			e.Logger.Info("Shutting down server...")
		}
	}
}()

When I supply my certificate file paths, I do not get any response from it, just that it is hanging there. I do not even get the fun “Echo” banner at the start of the server. Is this a problem with my code, or is this a certificate issue?