Closed apinstein closed 15 years ago
I think we should do it the github way. That is setting your public key and then using ssh to upload. It seems easy, secure and already proved. Also people are used to this.
If we use ssh to upload, how to we get our application to respond to it? I think this works well for github since git already runs over ssh...
I'm sure there are ways to address this. Maybe a hook to the ssh server or maybe just a cron job that will check for updates asynchronously. We get the new package, read the specs and update it on the server.
I think using http://us.php.net/manual/en/function.openssl-sign.php would be the easiest, the only downside being that PHP must be installed with openssl. However, at least on Mac and I am sure Linux, adding openssl is trivial. The macports version comes with OpenSSL by default.
maybe i'll try adding it real quick and see how hard it is.
So you want to POST the data with the signature and on the server side verify it with http://us.php.net/manual/en/function.openssl-verify.php . Yes... seems like a good way to go.
Exactly. Working on it now!
Ok it works! that was very easy. The client side is now done.
Server side can verify via:
$pubKey = openssl_get_publickey("
-----BEGIN PUBLIC KEY----- MIIBIDANBgkqhkiG9w0BAQEFAAOCAQ0AMIIBCAKCAQEAurW+d5EKeSv/C73yYYOV PXy1ZPqULmxwTKDVg7MzHRcB9nawFpn6NBYlOhnzzuf9XV44qjB3ItZ1fb57+J6EzDTWrmPpBIB9POC7n0nnuHAG3NJuEO2ljDRtYyFnFLBF9rBCWV8uwWktlgRLHlua8qM9QWMFEeDcr6CEef1dn5xHSe5dYVW5RUrYMoATXiDGu+2LICFH1PStM/bLav0/ yu0/wFdwRFzBwKDOd340fruSK95KxFU3/2yRBKY1w/My9BWS1qY3Ok9T8/kVf/IU IFXxFAGQQcePveXv/upMFR6cNQdY15WV8TPCLR0iYZlKvQ6/GfnAz1xE/jan59lT uQIBIw== -----END PUBLIC KEY----- "); $res = openssl_verify(file_get_contents($pkgTgzPath), base64_decode($signatureBase64), $pubKey, OPENSSL_ALGO_SHA1); switch ($res) { case 1: print 'CORRECT'; break; case 0: print 'INCORRECT'; break; case -1: print 'ERROR'; break; }
Ok, this is done. We are now using openssl PKI signing for all package uploads to ensure the posters are the authorized users.
We can try to persist decisions here: http://wiki.github.com/fgrehm/pearfarm/pearfarm-security
And discuss them wherever...