read certificate chain from SHLO

This commit is contained in:
Marten Seemann
2016-11-10 22:18:11 +07:00
parent c5f88e01f5
commit 0b8c883b71
2 changed files with 15 additions and 0 deletions

View File

@@ -25,6 +25,7 @@ type cryptoSetupClient struct {
stk []byte stk []byte
sno []byte sno []byte
diversificationNonce []byte diversificationNonce []byte
certManager *crypto.CertManager
} }
var _ crypto.AEAD = &cryptoSetupClient{} var _ crypto.AEAD = &cryptoSetupClient{}
@@ -45,6 +46,7 @@ func NewCryptoSetupClient(
connID: connID, connID: connID,
version: version, version: version,
cryptoStream: cryptoStream, cryptoStream: cryptoStream,
certManager: &crypto.CertManager{},
}, nil }, nil
} }
@@ -100,6 +102,13 @@ func (h *cryptoSetupClient) handleREJMessage(cryptoData map[Tag][]byte) error {
} }
} }
if crt, ok := cryptoData[TagCERT]; ok {
err := h.certManager.SetData(crt)
if err != nil {
return err
}
}
return nil return nil
} }

View File

@@ -63,6 +63,12 @@ var _ = Describe("Crypto setup", func() {
Expect(cs.sno).To(Equal(nonc)) Expect(cs.sno).To(Equal(nonc))
}) })
It("passes the certificates to the CertManager", func() {
tagMap[TagCERT] = []byte("invalid-cert")
err := cs.handleREJMessage(tagMap)
Expect(err).To(MatchError(qerr.ProofInvalid))
})
Context("Reading server configs", func() { Context("Reading server configs", func() {
It("reads a server config", func() { It("reads a server config", func() {
b := &bytes.Buffer{} b := &bytes.Buffer{}