Skip to content

Commit e2bd780

Browse files
committed
🐛 fix machine webhook encoding consistency
Signed-off-by: Alexander Eldeib <[email protected]>
1 parent 59dc2ea commit e2bd780

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

api/v1alpha3/azuremachine_validation.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ limitations under the License.
1717
package v1alpha3
1818

1919
import (
20+
"encoding/base64"
21+
2022
"golang.org/x/crypto/ssh"
2123
"k8s.io/apimachinery/pkg/util/validation/field"
2224
)
@@ -25,7 +27,13 @@ import (
2527
func ValidateSSHKey(sshKey string, fldPath *field.Path) field.ErrorList {
2628
allErrs := field.ErrorList{}
2729

28-
if _, _, _, _, err := ssh.ParseAuthorizedKey([]byte(sshKey)); err != nil {
30+
decoded, err := base64.StdEncoding.DecodeString(sshKey)
31+
if err != nil {
32+
allErrs = append(allErrs, field.Required(fldPath, "the SSH public key is not properly base64 encoded"))
33+
return allErrs
34+
}
35+
36+
if _, _, _, _, err := ssh.ParseAuthorizedKey(decoded); err != nil {
2937
allErrs = append(allErrs, field.Required(fldPath, "the SSH public key is not valid"))
3038
return allErrs
3139
}

0 commit comments

Comments
 (0)