|
Really nobody that can help?
|
|
|
|
|
I'm connecting to an EPP server via TCPclient and it's protected by SSL certificate authentication. The company that provides the EPP server said I needed to get a certificate (not self-signed), upload the CRT file into my user account, and then combine the CRT and KEY files into one (I choose PFX) that I will need to pass with each message in order to invoke an authorization / certificate combination. I've upload the CRT and created the PFX files fine.
I've tested this several ways (SSLstream, NetworkStream, StreamWriter/StreamReader) and none of them have been able to produce me with a readable response. At the same time, neither method produces any exceptions. From my testing it appears that I connect to the server okay, convert my string and write okay, but then either get a blank response or a jibberish response that looks like it might be encrypted? Below are two ways I've tried to do this (SSLstream & NetworkStream). You can see my code, plus a screenshot of the response.
SSLstream
Dim collection = New X509Certificate2Collection()
collection.Import("C:\\Users\\Drew\\Desktop\\testcert\\FIcert.pfx", "password", X509KeyStorageFlags.DefaultKeySet)
Dim store = New X509Store(StoreName.My)
store.Open(OpenFlags.ReadWrite)
Try
For Each certificate As X509Certificate2 In collection
store.Add(certificate)
Next
Finally
store.Close()
End Try
Dim hello As XElement = <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<hello/>
</epp>
Try
Dim client As New TcpClient(DRShost, 700)
Dim data As [Byte]() = System.Text.Encoding.ASCII.GetBytes(hello.ToString)
Dim callback As New RemoteCertificateValidationCallback(AddressOf CertificateValidationCallback)
Dim sslStream As New Security.SslStream(client.GetStream(), False, callback)
sslStream.AuthenticateAsClient(DRShost, collection, SslProtocols.[Default], False)
If sslStream.IsAuthenticated Then
MsgBox("IsAuthenticated: " & sslStream.IsAuthenticated)
MsgBox("IsMutuallyAuthenticated: " & sslStream.IsMutuallyAuthenticated)
MsgBox("IsEncrypted: " & sslStream.IsEncrypted)
MsgBox("IsSigned: " & sslStream.IsSigned)
MsgBox("IsServer: " & sslStream.IsServer)
End If
sslStream.Write(data, 0, data.Length)
MsgBox("Sent: " & hello.ToString)
data = New [Byte](256) {}
Dim bytes As Integer = sslStream.Read(data, 0, data.Length)
Dim responseData As String = System.Text.Encoding.ASCII.GetString(data, 0, bytes)
MsgBox("Received: " & responseData)
Catch ex As AuthenticationException
MsgBox(ex.Message)
Catch ex As SocketException
MsgBox(ex.Message)
Catch ex As IOException
MsgBox(ex.Message)
Finally
If sslStream IsNot Nothing Then
sslStream.Close()
End If
End Try
Response:
Screenshot Here
NetworkStream
Dim collection = New X509Certificate2Collection()
collection.Import("C:\\Users\\Drew\\Desktop\\testcert\\FIcert.pfx", "password", X509KeyStorageFlags.DefaultKeySet)
Dim store = New X509Store(StoreName.My)
store.Open(OpenFlags.ReadWrite)
Try
For Each certificate As X509Certificate2 In collection
store.Add(certificate)
Next
Finally
store.Close()
End Try
Dim hello As XElement = <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<hello/>
</epp>
Dim client As TcpClient = New TcpClient(DRShost, 700)
Dim tcpNetStream As NetworkStream = client.GetStream()
Dim sslStream As New Security.SslStream(tcpNetStream, False, New RemoteCertificateValidationCallback(AddressOf CertificateValidationCallback), Nothing)
sslStream.AuthenticateAsClient(DRShost, collection, SslProtocols.[Default], False)
Dim encodedBytes As Byte() = ASCIIEncoding.ASCII.GetBytes(hello.ToString)
tcpNetStream.Write(encodedBytes, 0, encodedBytes.Length)
Dim bytesToReceive As Byte() = New Byte(client.ReceiveBufferSize - 1) {}
Dim bytesRead As Integer = tcpNetStream.Read(bytesToReceive, 0, client.ReceiveBufferSize)
MsgBox("Received : " & Encoding.ASCII.GetString(bytesToReceive, 0, bytesRead))
client.Close()
Response:
Screenshot Here
I thought maybe the response from the second set of code was coming back encrypted, so I changed this line:
Dim bytesRead As Integer = tcpNetStream.Read(bytesToReceive, 0, client.ReceiveBufferSize)
To read from the sslStream instead. However, this just leads to once again receiving a blank response:
Dim bytesRead As Integer = sslStream.Read(bytesToReceive, 0, client.ReceiveBufferSize)
Any help on this would be greatly appreciated. I've scoured the web and tried everything I could think of, but to no avail. I do notice that when I view the string I'm sending it does not contain "". However, I believe that is added automatically by XElement?
|
|
|
|
|
Sorry, I thought my problem was a bad path problem but it turns out to be something else.
Although the information below is correct, the code recognizes the returned
path as a valid path.
Can someone tell me why this code does not return the complete path?
It seems like this 'old code' worked at one time.
Thank You
Const CSIDL_MYMUSIC as integer = 13 ' My Music
Const CSIDL_PERSONAL As Integer = 5 ' My Documents
<DllImport("Shell32", CharSet:=CharSet.Auto, SetLastError:=True)> _
Public Shared Function SHGetFolderPath(ByVal hWnd As IntPtr, ByVal csidl As Integer, _
ByVal handle As IntPtr, ByVal dwFlags As Integer, _
<MarshalAs(UnmanagedType.LPTStr)> ByVal lpBuffer As System.Text.StringBuilder) As Integer
End Function
For CSIDL_MYMUSIC the return value is "C:\users\myname.Home\Music" instead of "...\My Music"
For CSIDL_PERSONAL the return value is "C:\users\myname.Home\Documents" instead of "...\My Documents"
sub MyFunction()
Dim sb As New StringBuilder(200)
Dim sPath as string
SHGetFolderPath(IntPtr.Zero, CSIDL_MYMUSIC, IntPtr.Zero, 0, sb)
sPath = sb.ToString()
end sub
-- modified 28-Sep-18 18:04pm.
|
|
|
|
|
The names "My Documents", "My Music" etc. are shorthand links used by Explorer. If you open a command window and enter the command dir C:\ you will notice that they do not exist. And when you use the SHGetFolderPath function, it will always return the real full path for the relevant item.
|
|
|
|
|
Thank you for the information. Always good to learn something new.
|
|
|
|
|
|
Alright!!, something else new (to me). Thanks for the info.
|
|
|
|
|
Private Sub Combo1_Click()
Dim drs As New ADODB.Recordset
drs.Open "select * from room where roomno=" & CInt(Combo1.Text), con, 3, 2
If (Not drs.EOF Or drs.BOF) Then
Do Until drs.EOF
Me.Text2.Text = drs!price
drs.MoveNext
Loop
End If
End Sub
|
|
|
|
|
And? What is the question?
|
|
|
|
|
"VB6 lingua mortua est."
* You do not select *, just the rows columns you need
* You do not concatenate strings with unchecked user-input
* You do not load an entire recordset and loop, just to get a single attribute
* You do not code in VB6, not even if a Klingon demands it
* You do not have any question with your code-dump, and as such, should not expect much answers
Aw, and if you are going to be using this forum as your PA, at least be so kind to fill in your name.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Hello !
I'm writing a program in vb.net 2017 .
I need to have some forms in a specific size , for example 1180 x 700. The program run very well on users that have new monitors.
But the problem is that some users of this program , have old monitors that support up to 1024 x 768.
Do someone have an opinion how can I resolve this situation ?
Thank you !
|
|
|
|
|
I am assuming you are working on Windows Forms. If not, there is nothing that follows which will help.
Is there any specific reason why the form needs to be of that size? You might want to see TableLayoutPanel control to do control layout. In the panel, you can set column and row sizes to auto, fixed or percentage as per needs. Each cell can have only one control in the panel. The controls must have Dock set to Fill . The panel itself will also have Dock set to Fill (covering entire form).
This will ensure controls resize as the screen does.
"It is easy to decipher extraterrestrial signals after deciphering Javascript and VB6 themselves.", ISanti[ ^]
|
|
|
|
|
You should never do that. It is the user's choice what size the window should be. You just need to ensure that your form is clearly viewable on any screen size.
|
|
|
|
|
But this is my question , how can I do that my form will be clearly viewable on any screen size !!!
|
|
|
|
|
Take a look at the first reply from iw@. Build for the SMALLEST screen size and have the main control (usually a grid) able to resize (dockable, size="auto"). When viewed on a larger screen the main control then expands to use the available space leaving your peripheral controls (header or footer controls) the original size.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Can anyone tell me if c++ is worth learning or is it outdated?
|
|
|
|
|
Definitely not in the Visual Basic forum. Please don't crosspost it just duplicates effort and gets you a bad reputation.
|
|
|
|
|
Hello
I am using VBA from within the Rockwell (SCADA,PLC,...) Factory Talk View SCADA system.
I need to run a external (to the Factory talk view app) internet explorer process with the url (I use directly the IP) of a Bosch IPCamera. The windows security pop up for authentication comes to input user and password.
This is working fine. To do that from the VBA code i do this
Shell("C:\Program Files\Internet Explorer\iexplore.exe" & " http://192.168.50.11/",vbNormalFocus)
But I need to access directly without popup passing the credential from the VBA.
How can thi be done?
Thank you and regards
|
|
|
|
|
I am looking for a copy of vb.net
|
|
|
|
|
|
I tried Google. I couldn't find a download for Visual Basic.net
|
|
|
|
|
You need to look for Visual Studio.
|
|
|
|
|
VB.NET is a language. Not a downloadable component or app.
Visual Studio supports writing code in VB.NET, as well as a bunch of other languages, and it's free from the link I gave you.
|
|
|
|
|
|
|