Skip to content

Commit 46766a7

Browse files
Expose GIT_CERT_SSH_SHA256 (#690) (#694)
Newer versions of libssh2 use SHA256 fingerprints (cherry picked from commit 7497529) Co-authored-by: Hans Duedal <[email protected]>
1 parent 4f57b9b commit 46766a7

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

remote.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -172,17 +172,18 @@ type Certificate struct {
172172
type HostkeyKind uint
173173

174174
const (
175-
HostkeyMD5 HostkeyKind = C.GIT_CERT_SSH_MD5
176-
HostkeySHA1 HostkeyKind = C.GIT_CERT_SSH_SHA1
175+
HostkeyMD5 HostkeyKind = C.GIT_CERT_SSH_MD5
176+
HostkeySHA1 HostkeyKind = C.GIT_CERT_SSH_SHA1
177+
HostkeySHA256 HostkeyKind = C.GIT_CERT_SSH_SHA256
177178
)
178179

179-
// Server host key information. If Kind is HostkeyMD5 the MD5 field
180-
// will be filled. If Kind is HostkeySHA1, then HashSHA1 will be
181-
// filled.
180+
// Server host key information. A bitmask containing the available fields.
181+
// Check for combinations of: HostkeyMD5, HostkeySHA1, HostkeySHA256.
182182
type HostkeyCertificate struct {
183-
Kind HostkeyKind
184-
HashMD5 [16]byte
185-
HashSHA1 [20]byte
183+
Kind HostkeyKind
184+
HashMD5 [16]byte
185+
HashSHA1 [20]byte
186+
HashSHA256 [32]byte
186187
}
187188

188189
type PushOptions struct {
@@ -318,6 +319,7 @@ func certificateCheckCallback(_cert *C.git_cert, _valid C.int, _host *C.char, da
318319
cert.Hostkey.Kind = HostkeyKind(ccert._type)
319320
C.memcpy(unsafe.Pointer(&cert.Hostkey.HashMD5[0]), unsafe.Pointer(&ccert.hash_md5[0]), C.size_t(len(cert.Hostkey.HashMD5)))
320321
C.memcpy(unsafe.Pointer(&cert.Hostkey.HashSHA1[0]), unsafe.Pointer(&ccert.hash_sha1[0]), C.size_t(len(cert.Hostkey.HashSHA1)))
322+
C.memcpy(unsafe.Pointer(&cert.Hostkey.HashSHA256[0]), unsafe.Pointer(&ccert.hash_sha256[0]), C.size_t(len(cert.Hostkey.HashSHA256)))
321323
} else {
322324
cstr := C.CString("Unsupported certificate type")
323325
C.giterr_set_str(C.GITERR_NET, cstr)

0 commit comments

Comments
 (0)