how to check SSL certificate expiration date programmatically in Java

How to parse the expiration date from the certificate Cast it to an X509Certificate and call getNotAfter(). How to determine the certificate chain, eg, the github certificate with chains You’ve got it. That’s what the Certificate[] array is, as it says in the Javadoc. How did i know which certificate to get the expiration date … Read more

Authorization Bearer token in HttpClient?

I have come across similar situation, I was able to do it by following way, I hope this will help others. import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; public class HttpURLConnectionExample { public static void main(String[] args) throws Exception { // Sending get request URL url = new URL(“http://example-url”); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); … Read more

How do I manage cookies with HttpClient in Android and/or Java?

You need to use HttpContext. Set cookie store to context and pass context long with HttpGet/HttpPost in execute method. Hope this should help. See example: Complete code can be found here // Create a local instance of cookie store CookieStore cookieStore = new BasicCookieStore(); // Create local HTTP context HttpContext localContext = new BasicHttpContext(); // … Read more

HTTP Post requests using HttpClient take 2 seconds, why?

Allright, I solved this myself with some more investigation. All I had to do was to add a parameter that sets the HTTP Version to 1.1, as follows: HttpParams params = new BasicHttpParams(); params.setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1); HttpClient httpclient = new DefaultHttpClient(params); I found this thanks to the very nice HttpHelper Class from and-bookworm and some trial-and-error. … Read more

How to Handle the Session in Apache HttpClient 4.1

The correct way is to prepare a CookieStore which you need to set in the HttpContext which you in turn pass on every HttpClient#execute() call. HttpClient httpClient = new DefaultHttpClient(); CookieStore cookieStore = new BasicCookieStore(); HttpContext httpContext = new BasicHttpContext(); httpContext.setAttribute(HttpClientContext.COOKIE_STORE, cookieStore); // … HttpResponse response1 = httpClient.execute(method1, httpContext); // … HttpResponse response2 = httpClient.execute(method2, … Read more

How to disable caching with HttpClient get in Angular 6

Using meta HTML tags, Disable browser caching:- <meta http-equiv=”cache-control” content=”no-cache, must-revalidate, post-check=0, pre-check=0″> <meta http-equiv=”expires” content=”0″> <meta http-equiv=”pragma” content=”no-cache”> or, Add headers in http request as:- headers = new Headers({ ‘Cache-Control’: ‘no-cache, no-store, must-revalidate, post- check=0, pre-check=0’, ‘Pragma’: ‘no-cache’, ‘Expires’: ‘0’ });

HttpDelete with body

Have you tried overriding HttpEntityEnclosingRequestBase as follows: import org.apache.http.client.methods.HttpEntityEnclosingRequestBase; import java.net.URI; import org.apache.http.annotation.NotThreadSafe; @NotThreadSafe class HttpDeleteWithBody extends HttpEntityEnclosingRequestBase { public static final String METHOD_NAME = “DELETE”; public String getMethod() { return METHOD_NAME; } public HttpDeleteWithBody(final String uri) { super(); setURI(URI.create(uri)); } public HttpDeleteWithBody(final URI uri) { super(); setURI(uri); } public HttpDeleteWithBody() { super(); } } … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)