0

In order to sign data with personal digital signature in a web application, server side languages like PHP can do the whole job, but that would require that the user uploads his private key, lets say stored in PFX file, which would also require that he submit the (personal) password to unlock the PFX. Other alternative is to upload the already unlocked information in PEM format, which doesn't require the password, but the private key is much or more exposed as in the previous case.

What remains is to sign the data in the client machine, and submit the signed data together with the public key to the server.

As it is a web application i assume that would be done with JavaScript.

What would be the the most global (crossbrowser/"official") JavaScript solution?

If you think this is misleading I appreciate correction and guidance.

Thank you

closed as off-topic by Arseni Mourzenko, amon, GlenH7, Kilian Foth, user40980 Mar 19 '15 at 20:13

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions asking us to recommend a tool, library or favorite off-site resource are off-topic for Programmers as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it." – amon, Kilian Foth, Community
If this question can be reworded to fit the rules in the help center, please edit the question.

0

Yes, you are correct, you can either treat the server as trusted and put an unencrypted (or encrypted with the password next to it) private key in the server to let the server do the signing itself or you treat the server as untrusted medium and do the signing on the local machine. The latter can't be done with JavaScript solution though, as the JavaScript itself needs to be delivered by the server, and a malicious attacker can replace that JavaScript with something of their own making. The application that signs should be disconnected from the server for best security.

Those are really the two major tradeoffs. There is no single "correct" solution, what you should choose depends on your security and availability requirements.

If you really need both high security, high auditability, and high availability, then one option is to use a hardware token on the server. The hardware token is a special purpose hardware dedicated just for signing, and it is designed so the private key cannot be extracted from the token; at least not through a remote connection. An attacker has to be present at the machine to have a chance to extract the key. A hardware token wouldn't prevent the attacker that managed to gain remote access to the server from tricking the token to sign their content, but it will provide auditability, as the token can keep records of things it signs, that are stored in such way that cannot be tampered easily by the attacker.

Not the answer you're looking for? Browse other questions tagged or ask your own question.