Path: csiph.com!aioe.org!.POSTED.O5hsyUvK01te0L/SZurVSQ.user.gioia.aioe.org!not-for-mail From: =?UTF-8?Q?Arne_Vajh=c3=b8j?= Newsgroups: comp.lang.java.programmer Subject: Re: How to create a ssh/tls connection for a tcp connection in java Date: Fri, 3 Jan 2020 16:45:17 -0500 Organization: Aioe.org NNTP Server Lines: 22 Message-ID: References: <7e6fef16-b107-424a-89c2-f717f9a6d595@googlegroups.com> NNTP-Posting-Host: O5hsyUvK01te0L/SZurVSQ.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.1 X-Notice: Filtered by postfilter v. 0.9.2 Content-Language: en-US Xref: csiph.com comp.lang.java.programmer:39270 On 1/3/2020 8:34 AM, mike wrote: > I am working on creating a call-home function > https://tools.ietf.org/html/rfc8071 for java. > > Basically something like this: > AFAIK the tcp connection in java is done using sockets. But then my > question is how can convert that into a ssh/tls connection. Is there > a library that supports wrapping sockets into ssh/tls? SSLSocket is a sub class pf Socket, so you create a SSLSocket and use it like a Socket. There are a few variation ins how to create but maybe something like: SSLContext sslctx = SSLContext.getInstance("TLSv1.2"); sslctx.init(null, new X509TrustManager[] { new MyTrustManager() }, null); SSLSocket s = (SSLSocket) sslctx.getSocketFactory().createSocket(HOST, PORT); Arne