tgstation-server icon indicating copy to clipboard operation
tgstation-server copied to clipboard

You shouldn't need a public key to enable pushing changelogs

Open MrStonedOne opened this issue 7 years ago • 12 comments

The public key is already encoded in the private key, and I was able to git the git client to work without it.

upstream bugreport: libgit2/libgit2sharp#1468 upstream bugreport: libgit2/libgit2#4289

MrStonedOne avatar Jun 30 '17 11:06 MrStonedOne

I don't even have a public key file for the tgstation-server account, and I don't even know how to generate one (i bet it isn't hard, but i'm just not going to now out of principle)

MrStonedOne avatar Jun 30 '17 11:06 MrStonedOne

you 'git' it to do it did you? ;P

RemieRichards avatar Jun 30 '17 11:06 RemieRichards

That was intentional

MrStonedOne avatar Jun 30 '17 11:06 MrStonedOne

as was "now and days" and "rather it happens" I assume :^)

RemieRichards avatar Jun 30 '17 11:06 RemieRichards

Sadly, there's no function in the c# api to generate the public key from the private key. Git must have something else built in. However, you can generate it yourself using puttygen https://askubuntu.com/a/700275

Cyberboss avatar Jun 30 '17 14:06 Cyberboss

A quick look into this shows that there's no way for us to generate it in code without importing another crypto library alongside what LibGit2Sharp ships and that's not something I'm a fan of when the above solution works perfectly.

Cyberboss avatar Jun 30 '17 15:06 Cyberboss

Why do you need it?

MrStonedOne avatar Jun 30 '17 17:06 MrStonedOne

The issue lies in this function called from libgit2: https://www.libssh2.org/libssh2_userauth_publickey_fromfile_ex.html. Apparently the shipped libssh2 version doesn't include OpenSSL support because it will always fail without the public key

Cyberboss avatar Jun 30 '17 17:06 Cyberboss

why are we using an ssh library that is so out of active development its issue tracker has had spam on it for 4 months: http://trac.libssh2.org/ticket/310

And its last actual activity is over a year ago.

MrStonedOne avatar Jun 30 '17 18:06 MrStonedOne

Also. I needed to you explain the top level function you are calling that requires it, I was planning on doing the investigation you did.

Still need that.

MrStonedOne avatar Jun 30 '17 18:06 MrStonedOne

The credentials are created here: https://github.com/tgstation/tgstation-server/blob/master/TGServerService/Repository.cs#L745

Those map to a simple data holder in LibGit2Sharp which forwards them to the credentials provider: https://github.com/leobuskin/libgit2sharp-ssh/commit/bec6d39617faaebcbab5af0e2803a012b1bfd04d#diff-4df0bf63109ae12623c2accde500d8f8R16

That calls git_cred_ssh_key_new which in turn calls libssh2_userauth_public_key_fromfile_ex: https://github.com/libgit2/libgit2/blob/7849e467579f64ccbbfdc4463af97a215d1ac8e3/src/transports/ssh.c#L356

Cyberboss avatar Jun 30 '17 18:06 Cyberboss

Was too stupid back then to realize you could use a remote similar to git://<user>:<token>@github.com/<owner>/<repo> to make this work. Fixed in V4 anyways.

Cyberboss avatar Jul 13 '20 18:07 Cyberboss