mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-07 06:40:54 +03:00
don't allow DSA keys
Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
@@ -2907,11 +2907,18 @@ func validatePublicKeys(user *User) error {
|
||||
util.I18nErrorPubKeyInvalid,
|
||||
)
|
||||
}
|
||||
if out.Type() == ssh.InsecureKeyAlgoDSA {
|
||||
providerLog(logger.LevelError, "dsa public key not accepted, position: %d", idx)
|
||||
return util.NewI18nError(
|
||||
util.NewValidationError(fmt.Sprintf("DSA key format is insecure and it is not allowed for key at position %d", idx)),
|
||||
util.I18nErrorKeyInsecure,
|
||||
)
|
||||
}
|
||||
if k, ok := out.(ssh.CryptoPublicKey); ok {
|
||||
cryptoKey := k.CryptoPublicKey()
|
||||
if rsaKey, ok := cryptoKey.(*rsa.PublicKey); ok {
|
||||
if size := rsaKey.N.BitLen(); size < 2048 {
|
||||
providerLog(logger.LevelError, "rsa key with size %d not accepted, minimum 2048", size)
|
||||
providerLog(logger.LevelError, "rsa key with size %d at position %d not accepted, minimum 2048", size, idx)
|
||||
return util.NewI18nError(
|
||||
util.NewValidationError(fmt.Sprintf("invalid size %d for rsa key at position %d, minimum 2048",
|
||||
size, idx)),
|
||||
|
||||
@@ -121,6 +121,7 @@ const (
|
||||
I18nErrorPubKeyInvalid = "user.pub_key_invalid"
|
||||
I18nErrorPrivKeyInvalid = "user.priv_key_invalid"
|
||||
I18nErrorKeySizeInvalid = "user.key_invalid_size"
|
||||
I18nErrorKeyInsecure = "user.key_insecure"
|
||||
I18nErrorPrimaryGroup = "user.err_primary_group"
|
||||
I18nErrorDuplicateGroup = "user.err_duplicate_group"
|
||||
I18nErrorNoPermission = "user.no_permissions"
|
||||
|
||||
@@ -501,7 +501,8 @@
|
||||
"home_invalid": "The home directory must be an absolute path",
|
||||
"pub_key_invalid": "Invalid public key",
|
||||
"priv_key_invalid": "Invalid private key",
|
||||
"key_invalid_size": "Invalid RSA key: the minimum supported size is 2048",
|
||||
"key_invalid_size": "Invalid RSA public key: the minimum supported size is 2048",
|
||||
"key_insecure": "Insecure public key format not allowed",
|
||||
"err_primary_group": "Only one primary group is allowed",
|
||||
"err_duplicate_group": "Duplicate groups detected",
|
||||
"no_permissions": "Directories permissions are mandatory",
|
||||
|
||||
@@ -501,7 +501,8 @@
|
||||
"home_invalid": "La directory principale deve essere un path assoluto",
|
||||
"pub_key_invalid": "Chiave pubblica non valida",
|
||||
"priv_key_invalid": "Chiave privata non valida",
|
||||
"key_invalid_size": "Chiave RSA non valida: la dimensione minima supportata è 2048",
|
||||
"key_invalid_size": "Chiave pubblica RSA non valida: la dimensione minima supportata è 2048",
|
||||
"key_insecure": "Formato chiave pubblica non sicuro non consentito",
|
||||
"err_primary_group": "È consentito un solo gruppo primario",
|
||||
"err_duplicate_group": "Rilevati gruppi duplicati",
|
||||
"no_permissions": "I permessi per le directory sono obbligatori",
|
||||
|
||||
Reference in New Issue
Block a user