Skip to content
This repository has been archived by the owner on Sep 26, 2021. It is now read-only.

Commit

Permalink
Added NewService to allow custom tls.Config
Browse files Browse the repository at this point in the history
For example, you may want to load the certificate yourself, or to turn
off verification of SSL certificates to allow a TCP proxy to intercept
the connection for debugging.
  • Loading branch information
pranavraja committed May 30, 2013
1 parent d54db09 commit c7ffee5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions apns.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ type ApnsService struct {
conf *tls.Config
}

func NewService(host string, conf *tls.Config) *ApnsService {
return &ApnsService{host: host, conf: conf}
}

func (service *ApnsService) Connect() (err error) {
if service.conn != nil {
err = service.conn.Close()
Expand Down
10 changes: 10 additions & 0 deletions apns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,21 @@ package apns

import (
"bytes"
"crypto/tls"
"errors"
"testing"
"time"
)

func ExampleNewService(t *testing.T) {
config := new(tls.Config)
// Load certificate from the filesystem
cert, _ := tls.LoadX509KeyPair("cert.pem", "cert.private.pem")
config.Certificates = append(config.Certificates, cert)
service := NewService("gateway.sandbox.push.apple.com:2195", config)
service.Connect()
}

func BenchmarkNotificationSend(b *testing.B) {
queue := NewQueue()
for i := 0; i < b.N; i++ {
Expand Down

0 comments on commit c7ffee5

Please sign in to comment.