@@ -252,7 +252,7 @@ const (
252252// Certificate represents the two possible certificates which libgit2
253253// knows it might find. If Kind is CertficateX509 then the X509 field
254254// will be filled. If Kind is CertificateHostkey then the Hostkey
255- // field will be fille.d
255+ // field will be filled.
256256type Certificate struct {
257257 Kind CertificateKind
258258 X509 * x509.Certificate
@@ -266,7 +266,7 @@ const (
266266 HostkeyMD5 HostkeyKind = C .GIT_CERT_SSH_MD5
267267 HostkeySHA1 HostkeyKind = C .GIT_CERT_SSH_SHA1
268268 HostkeySHA256 HostkeyKind = C .GIT_CERT_SSH_SHA256
269- HostkeyRaw HostkeyKind = 1 << 3
269+ HostkeyRaw HostkeyKind = C . GIT_CERT_SSH_RAW
270270)
271271
272272// Server host key information. A bitmask containing the available fields.
@@ -476,6 +476,17 @@ func certificateCheckCallback(
476476 C .memcpy (unsafe .Pointer (& cert .Hostkey .HashMD5 [0 ]), unsafe .Pointer (& ccert .hash_md5 [0 ]), C .size_t (len (cert .Hostkey .HashMD5 )))
477477 C .memcpy (unsafe .Pointer (& cert .Hostkey .HashSHA1 [0 ]), unsafe .Pointer (& ccert .hash_sha1 [0 ]), C .size_t (len (cert .Hostkey .HashSHA1 )))
478478 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+ }
479490 } else {
480491 err := errors .New ("unsupported certificate type" )
481492 if data .errorTarget != nil {
0 commit comments