@@ -69,10 +69,13 @@ func TestNewSignerFromFilePolicy(t *testing.T) {
6969 },
7070 },
7171 }
72- _ , err := NewSignerFromFile (testCaFile , testCaKeyFile , CAConfig .Signing )
72+ signer , err := NewSignerFromFile (testCaFile , testCaKeyFile , CAConfig .Signing )
7373 if err != nil {
7474 t .Fatal (err )
7575 }
76+ if signer .lintPriv != nil {
77+ t .Error ("expected signer with LintErrLevel == 0 to have lintPriv == nil" )
78+ }
7679}
7780
7881func TestNewSignerFromFileInvalidPolicy (t * testing.T ) {
@@ -150,6 +153,51 @@ func TestNewSignerFromFileEdgeCases(t *testing.T) {
150153 }
151154}
152155
156+ func TestNewSignerFromFilePolicyLinting (t * testing.T ) {
157+ // CAConfig is a config that has an explicit "signature" profile that enables
158+ // pre-issuance linting.
159+ var CAConfig = & config.Config {
160+ Signing : & config.Signing {
161+ Profiles : map [string ]* config.SigningProfile {
162+ "signature" : {
163+ Usage : []string {"digital signature" },
164+ Expiry : expiry ,
165+ LintErrLevel : 3 ,
166+ },
167+ },
168+ Default : & config.SigningProfile {
169+ Usage : []string {"cert sign" , "crl sign" },
170+ ExpiryString : "43800h" ,
171+ Expiry : expiry ,
172+ CAConstraint : config.CAConstraint {IsCA : true },
173+ },
174+ },
175+ }
176+ signer , err := NewSignerFromFile (testCaFile , testCaKeyFile , CAConfig .Signing )
177+ if err != nil {
178+ t .Fatal (err )
179+ }
180+ // A CAConfig with a signing profile that sets LintErrLevel > 0 should have
181+ // a lintPriv key generated.
182+ if signer .lintPriv == nil {
183+ t .Error ("expected signer with profile LintErrLevel > 0 to have lintPriv != nil" )
184+ }
185+
186+ // Reconfigure caConfig so that the explicit "signature" profile doesn't
187+ // enable pre-issuance linting but the default profile does.
188+ CAConfig .Signing .Profiles ["signature" ].LintErrLevel = 0
189+ CAConfig .Signing .Default .LintErrLevel = 3
190+ signer , err = NewSignerFromFile (testCaFile , testCaKeyFile , CAConfig .Signing )
191+ if err != nil {
192+ t .Fatal (err )
193+ }
194+ // A CAConfig with a default profile that sets LintErrLevel > 0 should have
195+ // a lintPriv key generated.
196+ if signer .lintPriv == nil {
197+ t .Error ("expected signer with default profile LintErrLevel > 0 to have lintPriv != nil" )
198+ }
199+ }
200+
153201func TestSign (t * testing.T ) {
154202 s , err := NewSignerFromFile ("testdata/ca.pem" , "testdata/ca_key.pem" , nil )
155203 if err != nil {
0 commit comments