I am writing Java program proxy (man in the middle proxy). When the client connect to my proxy, i want to the server will send its self-certificate.
My problem is: How to auto generate self-certificate for every domain(using any tools: keytool, openssl,...) and sing to existed root ca? I want to when i imported root ca to browser(ex Firefox), it will not showing warning when client connect server through my proxy and i can decrypt data between the client and server.
In this case: I have two solutions:
1) I am writing a sh file include multiple command generate self-certificate and then execute it by java(Runtime.getRuntime().exec)
2) I found an module iaik_jce has an constructor method
cert = new iaik.x509.X509Certificate(server_cert.getEncoded());
: server_cert be get from statement: server_cert = (X509Certificate) socket.getSession().getPeerCertificates()[0];
but it is not supported all algorithm. I get an exception with google, facebook,...