mirror of
				https://github.com/therootcompany/greenlock.js.git
				synced 2024-11-16 17:29:00 +00:00 
			
		
		
		
	parse domains from cert info
This commit is contained in:
		
							parent
							
								
									40c336f204
								
							
						
					
					
						commit
						19d6ac68de
					
				| @ -35,6 +35,25 @@ certInfo.getCertInfo = function (pem) { | |||||||
|   return certSimpl; |   return certSimpl; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
|  | certInfo.getBasicInfo = function (pem) { | ||||||
|  |   var c = certInfo.getCertInfo(pem); | ||||||
|  |   var domains = []; | ||||||
|  | 
 | ||||||
|  |   c.extensions.forEach(function (ext) { | ||||||
|  |     if (ext.parsedValue && ext.parsedValue.altNames) { | ||||||
|  |       ext.parsedValue.altNames.forEach(function (alt) { | ||||||
|  |         domains.push(alt.Name); | ||||||
|  |       }); | ||||||
|  |     } | ||||||
|  |   }); | ||||||
|  | 
 | ||||||
|  |   return { | ||||||
|  |     issuedAt: c.notBefore.value | ||||||
|  |   , expiresAt: c.notAfter.value | ||||||
|  |   , domains: domains | ||||||
|  |   }; | ||||||
|  | }; | ||||||
|  | 
 | ||||||
| certInfo.getCertInfoFromFile = function (pemFile) { | certInfo.getCertInfoFromFile = function (pemFile) { | ||||||
|   return require('fs').readFileSync(pemFile, 'ascii'); |   return require('fs').readFileSync(pemFile, 'ascii'); | ||||||
| }; | }; | ||||||
| @ -45,6 +64,12 @@ certInfo.testGetCertInfo = function () { | |||||||
|   return certInfo.getCertInfo(certInfo.getCertInfoFromFile(pemFile)); |   return certInfo.getCertInfo(certInfo.getCertInfoFromFile(pemFile)); | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
|  | certInfo.testBasicCertInfo = function () { | ||||||
|  |   var path = require('path'); | ||||||
|  |   var pemFile = path.join(__dirname, '..', 'tests', 'example.cert.pem'); | ||||||
|  |   return certInfo.getBasicInfo(certInfo.getCertInfoFromFile(pemFile)); | ||||||
|  | }; | ||||||
|  | 
 | ||||||
| if (require.main === module) { | if (require.main === module) { | ||||||
|   var c = certInfo.testGetCertInfo(); |   var c = certInfo.testGetCertInfo(); | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -16,6 +16,12 @@ console.info(new Date(c.notAfter.value).valueOf()); | |||||||
| 
 | 
 | ||||||
| console.info(''); | console.info(''); | ||||||
| 
 | 
 | ||||||
|  | var json = certInfo.testBasicCertInfo(); | ||||||
|  | 
 | ||||||
|  | console.log(''); | ||||||
|  | console.log(JSON.stringify(json, null, '  ')); | ||||||
|  | console.log(''); | ||||||
|  | 
 | ||||||
| console.info(''); | console.info(''); | ||||||
| console.info('If we got values at all, it must have passed.'); | console.info('If we got values at all, it must have passed.'); | ||||||
| console.info(''); | console.info(''); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user