File tree Expand file tree Collapse file tree 2 files changed +21
-5
lines changed Expand file tree Collapse file tree 2 files changed +21
-5
lines changed Original file line number Diff line number Diff line change @@ -21,9 +21,11 @@ import (
21
21
"net"
22
22
"os"
23
23
"strings"
24
+ "text/template"
24
25
"time"
25
26
26
27
log "github.com/Sirupsen/logrus"
28
+ "github.com/gin-gonic/gin"
27
29
)
28
30
29
31
var (
@@ -215,3 +217,20 @@ func generateCertificates() {
215
217
log .Print ("written cert.cer" )
216
218
217
219
}
220
+
221
+ func certHandler (c * gin.Context ) {
222
+ if strings .Contains (c .Request .UserAgent (), "Firefox" ) {
223
+ c .Header ("content-type" , "application/x-x509-ca-cert" )
224
+ c .File ("ca.cert.cer" )
225
+ return
226
+ }
227
+ noFirefoxTemplate .Execute (c .Writer , c .Request .Host )
228
+ }
229
+
230
+ const noFirefoxTemplateHTML = `<!DOCTYPE html>
231
+
232
+
233
+
234
+ `
235
+
236
+ var noFirefoxTemplate = template .Must (template .New ("home" ).Parse (noFirefoxTemplateHTML ))
Original file line number Diff line number Diff line change @@ -75,11 +75,6 @@ func launchSelfLater() {
75
75
log .Println ("Done waiting 2 secs. Now launching..." )
76
76
}
77
77
78
- func certHandler (c * gin.Context ) {
79
- c .Header ("content-type" , "application/x-x509-ca-cert" )
80
- c .File ("cert.cer" )
81
- }
82
-
83
78
func main () {
84
79
85
80
flag .Parse ()
@@ -236,6 +231,8 @@ func main() {
236
231
ValidateHeaders : false ,
237
232
}))
238
233
234
+ r .LoadHTMLFiles ("templates/nofirefox.html" )
235
+
239
236
r .GET ("/" , homeHandler )
240
237
r .GET ("/certificate.crt" , certHandler )
241
238
r .POST ("/upload" , uploadHandler )
You can’t perform that action at this time.
0 commit comments