Quellcode durchsuchen

Fix sshagentkms

Back in "Implementation of the Prometheus endpoint (#1669)"
(dd1ff9c15b0f8ca5920dac6a0ff080b7f0cfb8be) the keyManager was wrapped in
another layer, which caused the key that ssh.Signer tries to use to be
a agent.Key, which ssh.Signer doesn't really know what to do with.

By inspecting the instrumentedKMSSigner to see if it wraps a
WrappedSSHSigner we can extract the original signer which works
with ssh.Signer and make sshagentkms work again.

Signed-off-by: Anton Lundin <glance@ac2.se>
Anton Lundin vor 1 Jahr
Ursprung
Commit
cb3a635f6c
1 geänderte Dateien mit 14 neuen und 0 gelöschten Zeilen
  1. 14 0
      authority/authority.go

+ 14 - 0
authority/authority.go

@@ -532,6 +532,13 @@ func (a *Authority) init() error {
 			switch s := signer.(type) {
 			case *sshagentkms.WrappedSSHSigner:
 				a.sshCAHostCertSignKey = s.Signer
+			case *instrumentedKMSSigner:
+				switch is := s.Signer.(type) {
+				case *sshagentkms.WrappedSSHSigner:
+					a.sshCAHostCertSignKey = is.Signer
+				default:
+					a.sshCAHostCertSignKey, err = ssh.NewSignerFromSigner(s)
+				}
 			case crypto.Signer:
 				a.sshCAHostCertSignKey, err = ssh.NewSignerFromSigner(s)
 			default:
@@ -558,6 +565,13 @@ func (a *Authority) init() error {
 			switch s := signer.(type) {
 			case *sshagentkms.WrappedSSHSigner:
 				a.sshCAUserCertSignKey = s.Signer
+			case *instrumentedKMSSigner:
+				switch is := s.Signer.(type) {
+				case *sshagentkms.WrappedSSHSigner:
+					a.sshCAUserCertSignKey = is.Signer
+				default:
+					a.sshCAUserCertSignKey, err = ssh.NewSignerFromSigner(s)
+				}
 			case crypto.Signer:
 				a.sshCAUserCertSignKey, err = ssh.NewSignerFromSigner(s)
 			default: