Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to connect to SSL TCP sockets using a trusted certificate (not self signed?) #30

Closed
spaghetti- opened this issue Jun 6, 2017 · 5 comments

Comments

@spaghetti-
Copy link

spaghetti- commented Jun 6, 2017

I have a server to which I can connect using openssl as so:

$ openssl s_client -connect example.com:port

and it establishes fine. The certificate is issued by Digicert.

How can I connect to this socket using BlueSSLService? I am using the follow code

import Socket
import SSLService

//snip
let conf = SSLService.Configuration();
let socket = try Socket.create(family: .inet, type: .stream, proto: .tcp);
socket.delegate = try SSLService(usingConfiguration: conf)

which fails with The operation couldn’t be completed. (Socket.SSLError error 0.)

I can only find documentation for self signed certificates in the repo.

@spaghetti-
Copy link
Author

I tried it again with a different domain (letsencrypt cert this time around) and I have the same error.

@billabt
Copy link
Collaborator

billabt commented Jun 7, 2017

Try using the following code to create the configuration:

	let config = SSLService.Configuration(withCipherSuite: nil)
        let socket = try Socket.create(family: .inet, type: .stream, proto: .tcp)
	socket.delegate = try SSLService(usingConfiguration: config)	

The default Configuration init method should not be used. In a future release of SSLService, this will be enforced.

Re-open this issue if you still have the problem after making the change. Thanks.

@billabt billabt closed this as completed Jun 7, 2017
@billabt
Copy link
Collaborator

billabt commented Jun 7, 2017

I just looked at it a bit more... There was a default constructor (due to improperly defaulting parameters) that was getting called. The change I suggested above will work for the current version however, in a future version (maybe later today), what you originally coded will work. Thanks for the find. I'm re-opening the issue pending the fix.

@billabt billabt reopened this Jun 7, 2017
@spaghetti-
Copy link
Author

The change above did indeed work for me. Thank you loads @billabt

@billabt
Copy link
Collaborator

billabt commented Jun 7, 2017

Glad the fix worked for you. It's now permanently fixed in 0.12.38. Using the default initializer will work as expected. Thanks again for finding this.

@billabt billabt closed this as completed Jun 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants