-
Notifications
You must be signed in to change notification settings - Fork 157
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
Start TLS_PSK_WITH_AES_128_CCM8 #76
Conversation
Codecov Report
@@ Coverage Diff @@
## master #76 +/- ##
==========================================
+ Coverage 69.67% 70.42% +0.74%
==========================================
Files 48 50 +2
Lines 2681 2847 +166
==========================================
+ Hits 1868 2005 +137
- Misses 579 600 +21
- Partials 234 242 +8
Continue to review full report at Codecov.
|
409f569
to
b6ef63c
Compare
Less edge cases to worry about Resolves #45
I am happy with this w/e I can get a review I would really appreciate it! |
This is awesome, thank you so much! I'm currently also on vacay but I have access to the IoT equipment at home, so I'll try to test this today. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice job!
I'm happy to say I've just managed to ping my IKEA Tradfri gateway with this! So this has been validated in protoduction 😄. If anyone's looking on and would like to try it, here's the sample code: package main
import (
"fmt"
"net"
"github.com/dustin/go-coap"
"github.com/pion/dtls"
)
func main() {
addr := &net.UDPAddr{IP: net.ParseIP("gateway-ip"), Port: 5684}
config := &dtls.Config{
PSK: func(_ []byte) ([]byte, error) {
return []byte("psk-on-bottom-of-gateway"), nil
},
PSKIdentityHint: []byte("Client_identity"), // For Tradfri Gateway the IdentityHint MUST be Client_identity
CipherSuites: []dtls.CipherSuiteID{dtls.TLS_PSK_WITH_AES_128_CCM8},
}
dtlsConn, err := dtls.Dial("udp", addr, config)
if err != nil {
panic(err)
}
defer dtlsConn.Close()
req := coap.Message{
Type: coap.Confirmable,
Code: coap.GET,
MessageID: 1,
Token: []byte{},
Payload: []byte{},
} // This is a CoAP Ping, empty confirmable message
data, err := req.MarshalBinary()
if err != nil {
panic(err)
}
_, err = dtlsConn.Write(data)
if err != nil {
panic(err)
}
resp := make([]byte, 2048)
dtlsConn.Read(resp)
msg, err := coap.ParseMessage(resp)
if err != nil {
panic(err)
}
fmt.Println(msg.MessageID)
fmt.Println(msg.Type)
fmt.Println(msg.Code)
fmt.Println(msg.Token)
fmt.Println(string(msg.Payload))
} It'll output:
|
@daenney that is awesome! So glad it works :) Thanks for doing half the work, really glad we did this. I am hoping we can get |
@daenney This works 100% !
OpenSSL <-> Pion
andPion <-> Pion
I am going on vacation on Tuesday, mind helping me catch corner cases etc...? Would love to get this merged and tagged :)