mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-07 14:50:55 +03:00
move plugin handling outside the sdk package
Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
14
util/util.go
14
util/util.go
@@ -11,6 +11,7 @@ import (
|
||||
"crypto/tls"
|
||||
"crypto/x509"
|
||||
"encoding/pem"
|
||||
"errors"
|
||||
"fmt"
|
||||
"html/template"
|
||||
"io"
|
||||
@@ -422,6 +423,19 @@ func GetTLSCiphersFromNames(cipherNames []string) []uint16 {
|
||||
return ciphers
|
||||
}
|
||||
|
||||
// EncodeTLSCertToPem returns the specified certificate PEM encoded.
|
||||
// This can be verified using openssl x509 -in cert.crt -text -noout
|
||||
func EncodeTLSCertToPem(tlsCert *x509.Certificate) (string, error) {
|
||||
if len(tlsCert.Raw) == 0 {
|
||||
return "", errors.New("invalid x509 certificate, no der contents")
|
||||
}
|
||||
publicKeyBlock := pem.Block{
|
||||
Type: "CERTIFICATE",
|
||||
Bytes: tlsCert.Raw,
|
||||
}
|
||||
return string(pem.EncodeToMemory(&publicKeyBlock)), nil
|
||||
}
|
||||
|
||||
// CheckTCP4Port quits the app if bind on the given IPv4 port fails.
|
||||
// This is a ugly hack to avoid to bind on an already used port.
|
||||
// It is required on Windows only. Upstream does not consider this
|
||||
|
||||
Reference in New Issue
Block a user