Search code examples
cryptographycertificatedigital-signatureclient-certificatesman-in-the-middle

Digital signature man in the middle attack prevention


I have client-side generated a digital signature(JavaScript). The signature is then verified on Java back end. To verify the signature I am passing to the backend - (signature value, public key and message for verification). So far so good, but then the question arises - What if someone performs a man in the middle attack? He can easily generate a signature and send his - (signature value, public key and message.). So in a sense, this makes my current implementation not secure enough.

How can I avoid this? As far as I researched I have to verify that the public key sent is coming from the appropriate client and this is done through CA (Certificate Authority). However, in my case, I am doing this as a final project in university and I am not sure how to approach this problem.

Should I generate the public key certificate on the client side and send them along with the public key? Is it possible to generate self-signed-certificates on client-side and then verify it on the back-end?


Solution

  • What if someone performs a man in the middle attack

    A MITM could replace the signature and the public key

    How can I avoid this?

    Mainly use SSL/TLS and/or...

    As far as I researched I have to verify that the public key sent is coming from the appropriate client and this is done through CA (Certificate Authority)

    If you use a Certificate Authority, each certificate is signed with the private key of the root CA certificate (or a subCA), so a MITM can not create a valid certificate because he does not own the root private key.

    At server side, you can validate that the signature has been performed with a private key that corresponds to a certificate issued by the CA. Note that in this case you are working with certificates, not just with public keys ( a certificate envelopes a public key).

    I am doing this as a final project in university and I am not sure how to approach this problem.

    You have explained your solution but not the background. I mean why do you decided you need a digital signature? without that information I can not advise you.

    Should I generate the public key certificate on the client side and send them along with the public key?

    Read my previous comment

    Is it possible to generate self-signed-certificates on client-side and then verify it on the back-end?

    Yes, of course. You can generate a key pair at client side and associate the public key with the user's account during the registration process (using a secure channel)

    This way you do not even need a password. The digital signature with the private key is the authentication proof. Using a CA is optional. The CA could issue a certificate containing the public key, but fot this scenario is not required