File: utils.go

package info (click to toggle)
golang-github-smallstep-crypto 0.63.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,800 kB
  • sloc: sh: 66; makefile: 50
file content (18 lines) | stat: -rw-r--r-- 429 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
package tlsutil

import (
	"net"

	"go.step.sm/crypto/x509util"
)

// SanitizeName converts the given domain to its ASCII form.
var SanitizeName = x509util.SanitizeName

// SanitizeHost returns the ASCII form of the host part in a host:port address.
func SanitizeHost(host string) (string, error) {
	if h, _, err := net.SplitHostPort(host); err == nil {
		return x509util.SanitizeName(h)
	}
	return x509util.SanitizeName(host)
}