@@ -252,7 +252,7 @@ const (
252
252
// Certificate represents the two possible certificates which libgit2
253
253
// knows it might find. If Kind is CertficateX509 then the X509 field
254
254
// will be filled. If Kind is CertificateHostkey then the Hostkey
255
- // field will be fille.d
255
+ // field will be filled.
256
256
type Certificate struct {
257
257
Kind CertificateKind
258
258
X509 * x509.Certificate
@@ -266,7 +266,7 @@ const (
266
266
HostkeyMD5 HostkeyKind = C .GIT_CERT_SSH_MD5
267
267
HostkeySHA1 HostkeyKind = C .GIT_CERT_SSH_SHA1
268
268
HostkeySHA256 HostkeyKind = C .GIT_CERT_SSH_SHA256
269
- HostkeyRaw HostkeyKind = 1 << 3
269
+ HostkeyRaw HostkeyKind = C . GIT_CERT_SSH_RAW
270
270
)
271
271
272
272
// Server host key information. A bitmask containing the available fields.
@@ -476,6 +476,17 @@ func certificateCheckCallback(
476
476
C .memcpy (unsafe .Pointer (& cert .Hostkey .HashMD5 [0 ]), unsafe .Pointer (& ccert .hash_md5 [0 ]), C .size_t (len (cert .Hostkey .HashMD5 )))
477
477
C .memcpy (unsafe .Pointer (& cert .Hostkey .HashSHA1 [0 ]), unsafe .Pointer (& ccert .hash_sha1 [0 ]), C .size_t (len (cert .Hostkey .HashSHA1 )))
478
478
C .memcpy (unsafe .Pointer (& cert .Hostkey .HashSHA256 [0 ]), unsafe .Pointer (& ccert .hash_sha256 [0 ]), C .size_t (len (cert .Hostkey .HashSHA256 )))
479
+ if (cert .Hostkey .Kind & HostkeyRaw ) == HostkeyRaw {
480
+ cert .Hostkey .Hostkey = C .GoBytes (unsafe .Pointer (ccert .hostkey ), C .int (ccert .hostkey_len ))
481
+ var err error
482
+ cert .Hostkey .SSHPublicKey , err = ssh .ParsePublicKey (cert .Hostkey .Hostkey )
483
+ if err != nil {
484
+ if data .errorTarget != nil {
485
+ * data .errorTarget = err
486
+ }
487
+ return setCallbackError (errorMessage , err )
488
+ }
489
+ }
479
490
} else {
480
491
err := errors .New ("unsupported certificate type" )
481
492
if data .errorTarget != nil {
0 commit comments