Forum » Programiranje » [Java]Brane spletne strani preko https
[Java]Brane spletne strani preko https
CWIZO ::
Mam en smotan problem, s katerim se ubadam že en dan pa pol. Na internetu nisem nch pametnega nasu...
Problem je v glavnem v tem da o javinih APIjih nimam kej prov velik pojma, ker so mi v službi tale projektek potruil sam mal za zravn...
Ok imam nek JSP oz. pac en java class, v katerem moram "odpreti" eno spletno stran ki je na https-u in brebrati celo vsebino v string. Zdej ce bi bil http pol znam in imam ze narejen, jebe me pa https.
Zaenkrat mam tkole:
Če to poženem mi vrže UnknownHostException, sam če grem pa preko browserja na ta naslov pa zadevo lepo odpre...
Ma kdo mogoče spisan kej takega že?
Problem je v glavnem v tem da o javinih APIjih nimam kej prov velik pojma, ker so mi v službi tale projektek potruil sam mal za zravn...
Ok imam nek JSP oz. pac en java class, v katerem moram "odpreti" eno spletno stran ki je na https-u in brebrati celo vsebino v string. Zdej ce bi bil http pol znam in imam ze narejen, jebe me pa https.
Zaenkrat mam tkole:
private BufferedReader getHttpsBufferedReader ( String URL ) throws UnknownHostException, IOException { Security.addProvider ( new com.sun.net.ssl.internal.ssl.Provider() ); SSLSocketFactory factory = (SSLSocketFactory)SSLSocketFactory.getDefault (); SSLSocket socket = (SSLSocket) factory.createSocket ( URL, 443 ); Writer out = new OutputStreamWriter ( socket.getOutputStream () ); // https requires the full URL in the GET line out.write ( "GET http://" + URL.substring ( 8 ) + "/ HTTP/1.1\r\n" ); out.write ( "\r\n" ); out.flush (); // read response BufferedReader in = new BufferedReader ( new InputStreamReader ( socket.getInputStream () ) ); out.close(); socket.close(); return in; }
Če to poženem mi vrže UnknownHostException, sam če grem pa preko browserja na ta naslov pa zadevo lepo odpre...
Ma kdo mogoče spisan kej takega že?
hancic.info
I can't uninstall it, there seems to be some kind of "Uninstall Shield"...
I can't uninstall it, there seems to be some kind of "Uninstall Shield"...
flush ::
Ja normalno če tlačiš URL kjer bi moral biti HOST.
Anyway, meni tole deluje:
Anyway, meni tole deluje:
import java.net.*; import java.io.*; public class HTTPSPost { static URL u; public static void main(String args[]) { try { HTTPSPost post = new HTTPSPost(); post.u = new URL("https://mail.google.com/mail/"); // Open the connection and prepare to POST URLConnection uc = u.openConnection(); uc.setDoOutput(true); uc.setDoInput(true); uc.setAllowUserInteraction(false); // Read Response InputStream in = uc.getInputStream(); int x; while ( (x = in.read()) != -1) { System.out.write(x); } in.close(); } catch (IOException e) { e.printStackTrace(); // should do real exception handling } } }
Noovo - Social Discovery Engine
http://www.noovo.com
http://www.noovo.com
Zgodovina sprememb…
- spremenil: flush ()
CWIZO ::
Sem probu še tkole zdele:
System.setProperty ( "java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol" );
Security.addProvider ( new com.sun.net.ssl.internal.ssl.Provider() );
URL url = new URL ( Location );
URLConnection connection = url.openConnection();
BufferedReader input = new BufferedReader ( new InputStreamReader ( connection.getInputStream() ) );
return input;
pa mi vrže tale exception:
sun.security.validator.ValidatorException: No trusted certificate found
Zdej pa kle jest zmrznem, ker je tole moj prvi stik s programiranjem ki ima kej veze s SSLom in certifikati, tak da pojma nimam kaj moram narediti oz. kaj sploh iskati.
System.setProperty ( "java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol" );
Security.addProvider ( new com.sun.net.ssl.internal.ssl.Provider() );
URL url = new URL ( Location );
URLConnection connection = url.openConnection();
BufferedReader input = new BufferedReader ( new InputStreamReader ( connection.getInputStream() ) );
return input;
pa mi vrže tale exception:
sun.security.validator.ValidatorException: No trusted certificate found
Zdej pa kle jest zmrznem, ker je tole moj prvi stik s programiranjem ki ima kej veze s SSLom in certifikati, tak da pojma nimam kaj moram narediti oz. kaj sploh iskati.
hancic.info
I can't uninstall it, there seems to be some kind of "Uninstall Shield"...
I can't uninstall it, there seems to be some kind of "Uninstall Shield"...
CWIZO ::
Qul, sem uporabil tisto zadevo da igoorera preverjanej certifikatov.
Ko se pa sistemc vrne mu bom pa rekel nej mi zrihta tele certifikate.
100x hvala!
Ko se pa sistemc vrne mu bom pa rekel nej mi zrihta tele certifikate.
100x hvala!
hancic.info
I can't uninstall it, there seems to be some kind of "Uninstall Shield"...
I can't uninstall it, there seems to be some kind of "Uninstall Shield"...
CWIZO ::
Hvala tudi tebi.
hancic.info
I can't uninstall it, there seems to be some kind of "Uninstall Shield"...
I can't uninstall it, there seems to be some kind of "Uninstall Shield"...
CWIZO ::
A mogoče kdo ve še kako omejit koliko časa java odpera neko stran.
Zdej mi namreč za vsak page čaka 20 sekund, jest bi pa recimo rad omejil na par sekund in da če v tem času ne dobi nač nazaj naj pač vrže exception... na netu nisem najdu nobene pametne rešitve za ta problem.
Zdej mi namreč za vsak page čaka 20 sekund, jest bi pa recimo rad omejil na par sekund in da če v tem času ne dobi nač nazaj naj pač vrže exception... na netu nisem najdu nobene pametne rešitve za ta problem.
hancic.info
I can't uninstall it, there seems to be some kind of "Uninstall Shield"...
I can't uninstall it, there seems to be some kind of "Uninstall Shield"...
jeti51 ::
Hm, narediš eno dodatno nit za branje tiste tvoje strani, vzporedno pa poženeš nek timer? Če se timer sproži, še preden prva nit konča, le-to ubiješ in vržeš Exception, če pa konča prej, pa uporabiš njene rezultate. Skratka timer uporabiš kot nek ansinhroni klic, kot nekakšno prekinitev.
Samo ideja...
Samo ideja...
CWIZO ::
Ja sem videl tut to rešitev.
No sej zdej sem našel tale HttpClient pa ma zadeva vse kar rabim.
Sam me spet ta kurčev SSL jebe. Je že lepo delal pa vse, pol je pa kr naenkrat nehalo delat če sem zahteval stran preko httpsja. Dokumentacijo imajo pa v kurcu.
Je že kdo delal s tem?
No sej zdej sem našel tale HttpClient pa ma zadeva vse kar rabim.
Sam me spet ta kurčev SSL jebe. Je že lepo delal pa vse, pol je pa kr naenkrat nehalo delat če sem zahteval stran preko httpsja. Dokumentacijo imajo pa v kurcu.
Je že kdo delal s tem?
hancic.info
I can't uninstall it, there seems to be some kind of "Uninstall Shield"...
I can't uninstall it, there seems to be some kind of "Uninstall Shield"...
CWIZO ::
Sva z adminom zdej dodala certifikate s keytool.exe pa dela kot namazano.
hancic.info
I can't uninstall it, there seems to be some kind of "Uninstall Shield"...
I can't uninstall it, there seems to be some kind of "Uninstall Shield"...
Vredno ogleda ...
Tema | Ogledi | Zadnje sporočilo | |
---|---|---|---|
Tema | Ogledi | Zadnje sporočilo | |
» | [JAVA] HTTPS clientOddelek: Programiranje | 3170 (1900) | peterv6i |
» | Java in pošiljanje elektronske pošte!!Oddelek: Programiranje | 1350 (1251) | janez_janez |
» | [JAVA] zaustavitev niti (threadov)Oddelek: Programiranje | 3170 (3170) | morbo |
» | [Delphi] client serverOddelek: Programiranje | 1265 (1124) | jvolk |
» | [java] Runtime.exec()Oddelek: Programiranje | 1878 (1751) | borchi |