I have a simple code for setting up a https connection to google and printing the response obtained.
import java.io.OutputStreamWriter;
import java.net.URL;
Either leave out conn.setDoOutput(true); or conn.setRequestMethod("GET"); because these two statements are contradicting. GET does not allow output and output on the other side means you can't use GET as request method.
It seems that you are trying to fetch the certificate from the SSL layer of the HTTPS protocol. For this, you do not need to send anythig (hence doOutput is not needed). Instead, the information that you want to get is sent to you as part of the SSL handshake inside of the connection establishing code of the HttpsURLConnection, and the SSLSocket which is part of this.
This will help you do what you are after: http://www.xinotes.org/notes/note/1088/