diff --git a/certificates/certificates.go b/certificates/certificates.go index a52599318..990fa2e01 100644 --- a/certificates/certificates.go +++ b/certificates/certificates.go @@ -30,13 +30,9 @@ import ( "math/big" "net" "os" - "strings" - "text/template" "time" - "github.com/arduino/arduino-create-agent/config" "github.com/arduino/go-paths-helper" - "github.com/gin-gonic/gin" log "github.com/sirupsen/logrus" ) @@ -262,23 +258,6 @@ func GenerateCertificates(certsDir *paths.Path) { } } -// CertHandler will expone the certificate (we do not know why this was required) -func CertHandler(c *gin.Context) { - if strings.Contains(c.Request.UserAgent(), "Firefox") { - c.Header("content-type", "application/x-x509-ca-cert") - c.File("ca.cert.cer") - return - } - noFirefoxTemplate.Execute(c.Writer, gin.H{ - "url": "http://" + c.Request.Host + c.Request.URL.String(), - }) -} - -// DeleteCertHandler will delete the certificates -func DeleteCertHandler(c *gin.Context) { - DeleteCertificates(config.GetCertificatesDir()) -} - // DeleteCertificates will delete the certificates func DeleteCertificates(certDir *paths.Path) { certDir.Join("ca.key.pem").Remove() @@ -288,105 +267,3 @@ func DeleteCertificates(certDir *paths.Path) { certDir.Join("cert.pem").Remove() certDir.Join("cert.cer").Remove() } - -const noFirefoxTemplateHTML = ` - - - - - - -
-

Oops, this is not Firefox

-
- -
-

You need to open this link in Firefox to trust this certificate: {{.host}}{{.url}}

-
- - -` - -var noFirefoxTemplate = template.Must(template.New("home").Parse(noFirefoxTemplateHTML)) diff --git a/main.go b/main.go index 0350f0f4a..8e665585a 100755 --- a/main.go +++ b/main.go @@ -22,6 +22,7 @@ import ( _ "embed" "encoding/json" "flag" + "html/template" "io" "os" "os/exec" @@ -29,7 +30,6 @@ import ( "runtime/debug" "strconv" "strings" - "text/template" "time" cors "github.com/andela/gin-cors" @@ -386,8 +386,6 @@ func loop() { r.LoadHTMLFiles("templates/nofirefox.html") r.GET("/", homeHandler) - r.GET("/certificate.crt", cert.CertHandler) - r.DELETE("/certificate.crt", cert.DeleteCertHandler) r.POST("/upload", uploadHandler) r.GET("/socket.io/", socketHandler) r.POST("/socket.io/", socketHandler) diff --git a/tests/test_certs.py b/tests/test_certs.py deleted file mode 100644 index aec25b491..000000000 --- a/tests/test_certs.py +++ /dev/null @@ -1,33 +0,0 @@ -# Copyright 2022 Arduino SA -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published -# by the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . - -import requests - - -def test_get_cert(base_url, agent): - - resp = requests.get(f"{base_url}/certificate.crt") - assert resp.status_code == 200 - - cert = resp.text - assert "" in cert - - -def test_del_cert(base_url, agent): - - resp = requests.delete(f"{base_url}/certificate.crt") - assert resp.status_code == 200 - - # Should rm "ca.cert.pem", "ca.cert.cer", "ca.key.pem"