mirror of
https://github.com/FiloSottile/mkcert.git
synced 2025-10-14 00:41:40 +08:00
cert: use os.Hostname for the OU, and add the long form user name
The output of the hostname command on Windows is probably UTF-16, but instead of figuring out its edge cases, switch to the syscall on every platform. Fixes #96 Closes #142
This commit is contained in:
12
cert.go
12
cert.go
@@ -34,12 +34,16 @@ import (
|
|||||||
var userAndHostname string
|
var userAndHostname string
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
u, _ := user.Current()
|
u, err := user.Current()
|
||||||
if u != nil {
|
if err == nil {
|
||||||
userAndHostname = u.Username + "@"
|
userAndHostname = u.Username + "@"
|
||||||
}
|
}
|
||||||
hostname, _ := os.Hostname()
|
if h, err := os.Hostname(); err == nil {
|
||||||
userAndHostname += hostname
|
userAndHostname += h
|
||||||
|
}
|
||||||
|
if err == nil && u.Name != "" && u.Name != u.Username {
|
||||||
|
userAndHostname += " (" + u.Name + ")"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *mkcert) makeCert(hosts []string) {
|
func (m *mkcert) makeCert(hosts []string) {
|
||||||
|
Reference in New Issue
Block a user