Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.BufferedReader;
- import java.io.InputStreamReader;
- import java.net.MalformedURLException;
- import java.net.URL;
- import java.security.NoSuchAlgorithmException;
- import javax.net.ssl.HttpsURLConnection;
- import javax.net.ssl.SSLContext;
- public class Prog {
- public static void main(String[] args) throws Exception {
- makeRequest();
- }
- public static void makeRequest() throws Exception {
- String url = "https://test-as.sgx.trustedservices.intel.com:443/attestation/sgx/v2/sigrl/00000010";
- URL target = new URL(url);
- /* Force TLSv1.2 */
- SSLContext sc = SSLContext.getInstance("TLSv1.2");
- sc.init(null, null, new java.security.SecureRandom());
- /* Set up HTTP properties. */
- HttpsURLConnection connection = (HttpsURLConnection) target.openConnection();
- connection.setSSLSocketFactory(sc.getSocketFactory());
- connection.setRequestMethod("GET");
- connection.setDoOutput(true);
- /* Obtain and check response status quote. */
- int responseCode = connection.getResponseCode();
- /* Read response body into a String */
- BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
- String inputLine;
- StringBuffer responseBuffer = new StringBuffer();
- while((inputLine = in.readLine()) != null){
- responseBuffer.append(inputLine);
- }
- in.close();
- String response = responseBuffer.toString();
- /* Evaluate result and print messages. */
- System.out.println("HTTP response status code: " + responseCode + "\n");
- System.out.println(response);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement