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

Support multiple certificates and certificate chains #53

Closed
dzianisv opened this issue Apr 5, 2019 · 5 comments
Closed

Support multiple certificates and certificate chains #53

dzianisv opened this issue Apr 5, 2019 · 5 comments
Labels

Comments

@dzianisv
Copy link

dzianisv commented Apr 5, 2019

Your environment.

Library usage

	dtlsConfig := &dtls.Config{
		Certificate: certificate,
		PrivateKey:  privateKey,
		ClientAuth:  dtls.RequestClientCert,
	}

	trackingContext := NewTrackingContext()

	listener, err := dtls.Listen("udp", bindAddr, dtlsConfig)
	if err != nil {
		logger.Fatal(err)
	}
	defer listener.Close()

	for {
		logger.Debug("Waiting for the new connection")
		conn, err := listener.Accept()
		if err != nil {
			logger.Debugf("Failed to accept a new connection: %s", err)
		}
		go communicate(conn.(*dtls.Conn), trackingContext)
	}

What did you do?

I tried to connect to the simple dtls server using

openssl s_client -dtls1_2 -cert cert.pem -key cert.key -mtu 1472 127.0.0.1:8080

and it works! But when I use a -cert_chain argument, dtls implementation fails:

openssl s_client -dtls1_2 -cert cert.pem -cert_chain cert.pem -key cert.key -mtu 1472 127.0.0.1:8080

What did you expect?

Successful handshake

What happened?

Logs from server implementation on golang:

2019-04-05T15:09:23.968+0300    DEBUG   signaling       signaling/main.go:167   Waiting for the new connection
2019-04-05T15:09:23.968+0300    DEBUG   signaling       signaling/main.go:47    Accepted a new connection from 127.0.0.1:37854
2019-04-05T15:09:23.968+0300    DEBUG   signaling       signaling/main.go:56    Read error: dtls: data length and declared length do not match
handleIncoming: Handshake not finished, dropping packet

image

@dzianisv
Copy link
Author

dzianisv commented Apr 5, 2019

@dzianisv
Copy link
Author

dzianisv commented Apr 5, 2019

cert.zip

@dzianisv
Copy link
Author

dzianisv commented Apr 5, 2019

Server works if client certificate authentication is disabled: ClientAuth: dtls.NoClientCert. I see the following handshake packets
image

@Sean-Der
Copy link
Member

Hey @denis4net!

Sorry I haven't had a chance to look at this yet. I am working on PSK at the moment, when that is complete I will come right back to this.

thanks for the patience :)

@Sean-Der Sean-Der changed the title dtls implementation doesn't manage to work with certificate chain Support multiple certificates and certificate chains Jul 24, 2019
@Sean-Der Sean-Der added difficulty:hard triaged Has been reviewed labels Jul 24, 2019
@aconchillo
Copy link

it seems this PR #99 would fix this.

Sean-Der pushed a commit that referenced this issue Nov 11, 2019
Breaking changes:
* certificate, privateKey was replaced
  by certificate (tls.Certificate)
* verifyPeerCertificates uses array of bytes for chain
  certificate instead of certificate(*x509.Certificate)

Resolves #53
Sean-Der pushed a commit that referenced this issue Nov 16, 2019
Breaking changes:
* certificate, privateKey was replaced
  by certificate (tls.Certificate)
* verifyPeerCertificates uses array of bytes for chain
  certificate instead of certificate(*x509.Certificate)

Resolves #53
Sean-Der pushed a commit that referenced this issue Nov 22, 2019
Breaking changes:
* certificate, privateKey was replaced
  by certificate (tls.Certificate)
* verifyPeerCertificates uses array of bytes for chain
  certificate instead of certificate(*x509.Certificate)

Resolves #53
Sean-Der pushed a commit that referenced this issue Nov 23, 2019
Breaking changes:
* certificate, privateKey was replaced
  by certificate (tls.Certificate)
* verifyPeerCertificates uses array of bytes for chain
  certificate instead of certificate(*x509.Certificate)

Resolves #53
Sean-Der pushed a commit that referenced this issue Nov 23, 2019
Breaking changes:
* certificate, privateKey was replaced
  by certificate (tls.Certificate)
* verifyPeerCertificates uses array of bytes for chain
  certificate instead of certificate(*x509.Certificate)

Resolves #53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants