osdir.com
mailing list archive

Subject: Re: A series of minor patches from Debian - msg#00010

List: network.stunnel.user

Date: Prev Next Index Thread: Prev Next Index
Hi Luis,

{
I'm kind of new to this app. If you'll give me a thorough description
of the problem, I'll have a go at it. A link to some previous bug
report is fine.
}

It is not a bug; it is (at present and for some unknow reason) an
architectural limitation of STUNNEL. I simply wish to specify the MSG_OOB
flag in my client's C Socket SEND call, or use the (below) sendUrgentData()
Java method, and have STUNNEL just faithfully replay it to the destination
TCP/IP port. Am I asking too much?

Cheers Richard Maher


import java.io.BufferedOutputStream;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.UnknownHostException;
import java.net.SocketTimeoutException;
import java.lang.System;
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;

public class Tier3Socket
{
public static final
String T3ID="T3$";
public static final
int USERSIZ=40;
public static final
int T3IDBUFSIZ=48;
public static final
int CREDBUFSIZ=80;
public static final
int CONTIMOUT=3000;

public byte [] t3IdBuf;
public byte [] readBuf;
public byte [] writeBuf;

private String host;
private int port;
private int maxBufSiz;
private int bytesIn;
private String hostCharSet;
private Socket t3Sock;
private SSLSocketFactory sockFactory;
private BufferedInputStream in;
private BufferedOutputStream out;
private byte [] outUser;
private byte [] outPwd;
private byte [] credBuf;
private String inMsg;
private String stringOut;
private boolean sslReqd;

Tier3Socket (String host, int port, int maxBufSiz, String hostCharSet,
boolean sslReqd)
{
this.host = host;
this.port = port;
this.maxBufSiz = maxBufSiz;
this.hostCharSet = hostCharSet;
this.bytesIn = 0;
this.sslReqd = sslReqd;

t3IdBuf = new byte[T3IDBUFSIZ];
readBuf = new byte[maxBufSiz];

if (sslReqd)
sockFactory = (SSLSocketFactory)SSLSocketFactory.getDefault();
}

public void open() throws UnknownHostException, IOException
{
if (sslReqd)
t3Sock = (SSLSocket)sockFactory.createSocket();
else
t3Sock = new Socket();

t3Sock.setKeepAlive(true);
t3Sock.setReuseAddress(true);
t3Sock.setTcpNoDelay(true);
t3Sock.connect(new InetSocketAddress(host,port), CONTIMOUT);

in = new BufferedInputStream (t3Sock.getInputStream() ,maxBufSiz);
out = new BufferedOutputStream (t3Sock.getOutputStream(),maxBufSiz);

if (sslReqd)
{
((SSLSocket)t3Sock).setUseClientMode(true);

try {((SSLSocket)t3Sock).startHandshake();}
catch (IOException e)
{
System.out.println("Failed SSL Handshake");
throw new IOException("Can't SSL on Socket");
}
}
}

public void handShake(String username, String password) throws IOException
{
credBuf = new byte[CREDBUFSIZ];

outUser = username.getBytes(hostCharSet);
System.arraycopy(outUser, 0, credBuf, 0, outUser.length);

outPwd = password.getBytes(hostCharSet);
System.arraycopy(outPwd, 0, credBuf, USERSIZ, outPwd.length);

out.write(credBuf, 0, CREDBUFSIZ);
out.flush();

if (in.read(t3IdBuf) < t3IdBuf.length)
{
System.out.println("Read < " + Integer.toString(t3IdBuf.length) + "
bytes");
throw new IOException();
}

inMsg = new String(t3IdBuf, 0, 3, hostCharSet);

if (!inMsg.equals(T3ID))
{
throw new IOException();
}
}

public void sendUrgentData (int oob) throws IOException
{
t3Sock.sendUrgentData(oob);
}

public void setTimeout(int msecs) throws UnknownHostException, IOException
{
t3Sock.setSoTimeout(msecs);
}

public void close () throws IOException
{
if (t3Sock != null && !t3Sock.isClosed())
{
try {t3Sock.close();}
catch (Exception e)
{e.printStackTrace();}
}
}

public void buffMessage (String message) throws IOException
{
byte [] msg = message.getBytes(hostCharSet);

out.write(msg);
}

public void sendMessage (String message) throws IOException
{
byte [] msg = message.getBytes(hostCharSet);

out.write(msg);
flush();
}

public void flush () throws IOException
{
out.flush();
}

public int readMessage () throws IOException
{
return readMessage(readBuf.length);
}

public int readMessage (int bytes) throws IOException
{
try
{
bytesIn = in.read(readBuf, 0, bytes);
}
catch (SocketTimeoutException e)
{
return 0;
}

return bytesIn;
}

public String getString () throws ArrayIndexOutOfBoundsException
{
return getString(0, bytesIn);
}

public String getString (int offset, int length) throws
ArrayIndexOutOfBoundsException
{
if ((offset + length) > bytesIn)
{
throw new ArrayIndexOutOfBoundsException();
}
try
{
stringOut = new String(readBuf, offset, length, hostCharSet);
}
catch (Exception e)
{
return null;
}

return stringOut;
}

}

----- Original Message -----
From: "Luis Rodrigo Gallardo Cruz" <rodrigo@xxxxxxxxxxx>
To: <stunnel-users@xxxxxxxx>
Sent: Saturday, September 15, 2007 9:20 AM
Subject: Re: [stunnel-users] A series of minor patches from Debian


> _______________________________________________
> stunnel-users mailing list
> stunnel-users@xxxxxxxx
> http://stunnel.mirt.net/mailman/listinfo/stunnel-users
>

_______________________________________________
stunnel-users mailing list
stunnel-users@xxxxxxxx
http://stunnel.mirt.net/mailman/listinfo/stunnel-users



Was this page helpful?
Yes No
Thread at a glance:

Previous Message by Date: click to view message preview

Re: A series of minor patches from Debian

On Sat, Sep 15, 2007 at 07:04:43AM +0800, Richard's Hotmail wrote: > Hi Luis, > > While you're fixing things I don't suppose you'd fancy changing the > Out-Of-Band character handling so that STUNNEL honours a *non*-inlined OOB > and replays it to the application socket would you? I'm kind of new to this app. If you'll give me a thorough description of the problem, I'll have a go at it. A link to some previous bug report is fine. -- Rodrigo Gallardo GPG-Fingerprint: 7C81 E60C 442E 8FBC D975 2F49 0199 8318 ADC9 BC28 signature.asc Description: Digital signature _______________________________________________ stunnel-users mailing list stunnel-users@xxxxxxxx http://stunnel.mirt.net/mailman/listinfo/stunnel-users

Next Message by Date: click to view message preview

Re: A series of minor patches from Debian

On Sat, Sep 15, 2007 at 07:39:11PM +0800, Richard's Hotmail wrote: > Hi Luis, > > { > I'm kind of new to this app. If you'll give me a thorough description > of the problem, I'll have a go at it. A link to some previous bug > report is fine. > } > > It is not a bug; it is (at present and for some unknow reason) an > architectural limitation of STUNNEL. I simply wish to specify the MSG_OOB > flag in my client's C Socket SEND call, or use the (below) sendUrgentData() > Java method, and have STUNNEL just faithfully replay it to the destination > TCP/IP port. Am I asking too much? I'll look into it. I think you *might* be asking too much, because if you're talking to stunnel the other side might be past a socket type that doesn't allow for oob data (a pipe, for example). Also, I need to find out how this interacts with ssl. Anyways, I'll let you know what I find out. signature.asc Description: Digital signature _______________________________________________ stunnel-users mailing list stunnel-users@xxxxxxxx http://stunnel.mirt.net/mailman/listinfo/stunnel-users

Previous Message by Thread: click to view message preview

Re: A series of minor patches from Debian

On Sat, Sep 15, 2007 at 07:04:43AM +0800, Richard's Hotmail wrote: > Hi Luis, > > While you're fixing things I don't suppose you'd fancy changing the > Out-Of-Band character handling so that STUNNEL honours a *non*-inlined OOB > and replays it to the application socket would you? I'm kind of new to this app. If you'll give me a thorough description of the problem, I'll have a go at it. A link to some previous bug report is fine. -- Rodrigo Gallardo GPG-Fingerprint: 7C81 E60C 442E 8FBC D975 2F49 0199 8318 ADC9 BC28 signature.asc Description: Digital signature _______________________________________________ stunnel-users mailing list stunnel-users@xxxxxxxx http://stunnel.mirt.net/mailman/listinfo/stunnel-users

Next Message by Thread: click to view message preview

Re: A series of minor patches from Debian

On Sat, Sep 15, 2007 at 07:39:11PM +0800, Richard's Hotmail wrote: > Hi Luis, > > { > I'm kind of new to this app. If you'll give me a thorough description > of the problem, I'll have a go at it. A link to some previous bug > report is fine. > } > > It is not a bug; it is (at present and for some unknow reason) an > architectural limitation of STUNNEL. I simply wish to specify the MSG_OOB > flag in my client's C Socket SEND call, or use the (below) sendUrgentData() > Java method, and have STUNNEL just faithfully replay it to the destination > TCP/IP port. Am I asking too much? I'll look into it. I think you *might* be asking too much, because if you're talking to stunnel the other side might be past a socket type that doesn't allow for oob data (a pipe, for example). Also, I need to find out how this interacts with ssl. Anyways, I'll let you know what I find out. signature.asc Description: Digital signature _______________________________________________ stunnel-users mailing list stunnel-users@xxxxxxxx http://stunnel.mirt.net/mailman/listinfo/stunnel-users
Sign up for updates to this mailing list. email:
Loading Comments...
Home | News | Patents | Sitemap | FAQ | advertise

Advertising by