client: -server-cert pins the server certificate
Accept the server only if it presents exactly the given certificate (PEM or DER file), with no CA or hostname check, like the SoftEther client's CheckServerCert + ServerCert. Lets a self-signed server certificate that names no host be verified instead of turning verification off with -insecure. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
4c2b4dcec1
commit
bb92a9b954
4 changed files with 44 additions and 7 deletions
|
|
@ -40,6 +40,7 @@ type Config struct {
|
|||
Password string // Password (hashed or sent plain depending on PlainPassword)
|
||||
PlainPassword bool // If true, send password as plaintext (AuthType 2)
|
||||
InsecureSkipVerify bool // Skip TLS certificate verification
|
||||
ServerCert []byte // Pinned server certificate (DER); nil = CA and hostname verification
|
||||
}
|
||||
|
||||
// Session represents an established SoftEther VPN session.
|
||||
|
|
@ -60,7 +61,7 @@ func Connect(cfg Config) (*Session, error) {
|
|||
}
|
||||
|
||||
// Step 1: TLS connection
|
||||
conn, err := protocol.DialTLS(cfg.Host, cfg.Port, cfg.InsecureSkipVerify)
|
||||
conn, err := protocol.DialTLS(cfg.Host, cfg.Port, cfg.InsecureSkipVerify, cfg.ServerCert)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("connect: %w", err)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue