WrathChaos / StompClientLib

Simple STOMP Client library, Swift 3 and 4, 4.2, 5 compatible
https://www.freakycoder.com
MIT License
154 stars 81 forks source link

Self sign certificate, 400 error #66

Closed jbarros35 closed 4 years ago

jbarros35 commented 5 years ago

Hi, I tried on development a self signed certificate, but we could not connect. Using a default no secure it works but it cannot run on a real device. Do you have any advice?

    self.socketClient = StompClientLib()
    let url = NSURL(string: "wss://192.168.1.134:9002/api/ws")!
    socketClient.openSocketWithURLRequest(request: NSURLRequest(url: url as URL) , delegate: self)
    // auto reconnect
    socketClient.reconnect(request: NSURLRequest(url: url as URL) , delegate: self, time: 15.0)

Error: didFailWithError: Optional(Error Domain=SRWebSocketErrorDomain Code=2132 "received bad response code from server 400" UserInfo={NSLocalizedDescription=received bad response code from server 400, HTTPResponseStatusCode=400}) 2019-08-22 10:14:30.791461+0100 loxy4-app[8836:6292750] [Debug] [main] [WebSocketConnection.swift:60] serverDidSendError(client:withErrorMessage:detailedErrorMessage:) > received bad response code from server 400 didFailWithError: Optional(Error Domain=SRWebSocketErrorDomain Code=2132 "received bad response code from server 400" UserInfo={NSLocalizedDescription=received bad response code from server 400, HTTPResponseStatusCode=400})

Device: iPhone 6s IOS 12.4 StompClientLib version: Using StompClientLib (1.3.2)

jbarros35 commented 5 years ago

I added socketClient.certificateCheckEnabled = false but nothing happens. we are using NGINX on the server.

WrathChaos commented 5 years ago

Hello @jbarros35, I have never tried it with a selfed signed certificate one. Can you provide me with a simple example to let me work on it?

jbarros35 commented 5 years ago

I created a certificate signed locally on my Mac, and after, I loaded it and ran on websocketd. It cannot be read by API.

siddharthsuneel commented 5 years ago

@jbarros35 how can we load the self signed certificate while using this stompClientLib ?

Please let me know this so that I can also try this to workout some solution for Issue #67

jbarros35 commented 5 years ago

Done, we moved the server for a backend with a valid certificate.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.