Current location - Quotes Website - Personality signature - How to initiate http and https requests in java
How to initiate http and https requests in java

1.Write/","GET",null);

System.out.println(s);

}

The result is:

/","GET",null);

System.out.println(s);

}

< p>The result is:

Visible/ Take this URL as an example.

1) Visit / on the browser.

2) Click on the ×-marked lock in the picture above to view the certificate.

3) Select Copy to file for export. We import it into the security folder under the lib file of jre used in the java project. Mine is this path. D:\Program Files (x86)\Java\jre8\lib\security

Note: You need to choose the export format in the middle, just choose the default one. You also need to name it. I named it 12306.

2. Open cmd and enter the security directory under the lib file of jre used in the java project.

3. Enter Keytool -import -alias 12306 -file 12306.cer -keystore cacerts on the command line

4. After pressing Enter, you will be asked to enter the password. The default is changeit. Enter is not displayed. After entering it, just press Enter and you will be asked to confirm whether you trust the certificate. If you enter y, you will be prompted to import successfully.

5. After the import is successful, you can request /","GET",null);

System.out.println(s);

}

Result:

Now you can use http method to request https.

Note: Sometimes this step will still go wrong, it may be the jre version. No, we right-click run as-run configurations, select the jre where the certificate is located, and then run it.