{"action":"created","issue":{"url":"https://api.github.com/repos/PeculiarVentures/PKI.js/issues/179","repository_url":"https://api.github.com/repos/PeculiarVentures/PKI.js","labels_url":"https://api.github.com/repos/PeculiarVentures/PKI.js/issues/179/labels{/name}","comments_url":"https://api.github.com/repos/PeculiarVentures/PKI.js/issues/179/comments","events_url":"https://api.github.com/repos/PeculiarVentures/PKI.js/issues/179/events","html_url":"https://github.com/PeculiarVentures/PKI.js/issues/179","id":334150708,"node_id":"MDU6SXNzdWUzMzQxNTA3MDg=","number":179,"title":"Error on subjectUniqueID creation in Certificate","user":{"login":"microshine","id":7333669,"node_id":"MDQ6VXNlcjczMzM2Njk=","avatar_url":"https://avatars3.githubusercontent.com/u/7333669?v=4","gravatar_id":"","url":"https://api.github.com/users/microshine","html_url":"https://github.com/microshine","followers_url":"https://api.github.com/users/microshine/followers","following_url":"https://api.github.com/users/microshine/following{/other_user}","gists_url":"https://api.github.com/users/microshine/gists{/gist_id}","starred_url":"https://api.github.com/users/microshine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/microshine/subscriptions","organizations_url":"https://api.github.com/users/microshine/orgs","repos_url":"https://api.github.com/users/microshine/repos","events_url":"https://api.github.com/users/microshine/events{/privacy}","received_events_url":"https://api.github.com/users/microshine/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":{"login":"YuryStrozhevsky","id":6128446,"node_id":"MDQ6VXNlcjYxMjg0NDY=","avatar_url":"https://avatars0.githubusercontent.com/u/6128446?v=4","gravatar_id":"","url":"https://api.github.com/users/YuryStrozhevsky","html_url":"https://github.com/YuryStrozhevsky","followers_url":"https://api.github.com/users/YuryStrozhevsky/followers","following_url":"https://api.github.com/users/YuryStrozhevsky/following{/other_user}","gists_url":"https://api.github.com/users/YuryStrozhevsky/gists{/gist_id}","starred_url":"https://api.github.com/users/YuryStrozhevsky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/YuryStrozhevsky/subscriptions","organizations_url":"https://api.github.com/users/YuryStrozhevsky/orgs","repos_url":"https://api.github.com/users/YuryStrozhevsky/repos","events_url":"https://api.github.com/users/YuryStrozhevsky/events{/privacy}","received_events_url":"https://api.github.com/users/YuryStrozhevsky/received_events","type":"User","site_admin":false},"assignees":[{"login":"YuryStrozhevsky","id":6128446,"node_id":"MDQ6VXNlcjYxMjg0NDY=","avatar_url":"https://avatars0.githubusercontent.com/u/6128446?v=4","gravatar_id":"","url":"https://api.github.com/users/YuryStrozhevsky","html_url":"https://github.com/YuryStrozhevsky","followers_url":"https://api.github.com/users/YuryStrozhevsky/followers","following_url":"https://api.github.com/users/YuryStrozhevsky/following{/other_user}","gists_url":"https://api.github.com/users/YuryStrozhevsky/gists{/gist_id}","starred_url":"https://api.github.com/users/YuryStrozhevsky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/YuryStrozhevsky/subscriptions","organizations_url":"https://api.github.com/users/YuryStrozhevsky/orgs","repos_url":"https://api.github.com/users/YuryStrozhevsky/repos","events_url":"https://api.github.com/users/YuryStrozhevsky/events{/privacy}","received_events_url":"https://api.github.com/users/YuryStrozhevsky/received_events","type":"User","site_admin":false}],"milestone":null,"comments":0,"created_at":"2018-06-20T16:12:13Z","updated_at":"2018-06-21T06:51:10Z","closed_at":"2018-06-21T06:51:10Z","author_association":"NONE","body":"Cannot encode SubjectUniqueID for Certificate\r\n\r\n#### Certificate schema has subjectUniqueID and empty extensions\r\n```\r\nTypeError: Cannot read property 'toSchema' of undefined\r\n    at Certificate.encodeTBS (node_modules/pkijs/src/Certificate.js:443:29)\r\n    at Certificate.toSchema (node_modules/pkijs/src/Certificate.js:488:21)\r\n```\r\n\r\nIssuerUniqueID works fine\r\n\r\nThere are 2 `subjectUniqueID` implementations in `encodeTBS` method\r\nhttps://github.com/PeculiarVentures/PKI.js/blob/master/src/Certificate.js#L423-L445\r\n\r\n#### test app\r\n```js\r\nconst certificate = new Certificate();\r\n\r\nconst alg: RsaHashedKeyGenParams = {\r\n  name: \"RSASSA-PKCS1-v1_5\",\r\n  hash: \"SHA-256\",\r\n  publicExponent: new Uint8Array([1, 0, 1]),\r\n  modulusLength: 2048,\r\n};\r\n\r\nconst keys = await crypto.subtle.generateKey(alg, false, [\"sign\", \"verify\"]);\r\n\r\ncertificate.version = 2;\r\ncertificate.serialNumber = new Integer({ value: 1 });\r\n\r\ncertificate.notBefore.value = new Date();\r\ncertificate.notAfter.value = new Date();\r\ncertificate.notAfter.value.setFullYear(certificate.notAfter.value.getFullYear() + 1);\r\n\r\ncertificate.subjectUniqueID = Convert.FromHex(\"0102030405060708090001020304050607080900\");\r\n\r\nawait certificate.subjectPublicKeyInfo.importKey(keys.publicKey);\r\n\r\nawait certificate.sign(keys.privateKey, (keys.privateKey.algorithm as any).hash.name);\r\n\r\nconst certificateBuffer = certificate.toSchema(true).toBER(false); // Error is here\r\n```"},"comment":{"url":"https://api.github.com/repos/PeculiarVentures/PKI.js/issues/comments/398995259","html_url":"https://github.com/PeculiarVentures/PKI.js/issues/179#issuecomment-398995259","issue_url":"https://api.github.com/repos/PeculiarVentures/PKI.js/issues/179","id":398995259,"node_id":"MDEyOklzc3VlQ29tbWVudDM5ODk5NTI1OQ==","user":{"login":"YuryStrozhevsky","id":6128446,"node_id":"MDQ6VXNlcjYxMjg0NDY=","avatar_url":"https://avatars0.githubusercontent.com/u/6128446?v=4","gravatar_id":"","url":"https://api.github.com/users/YuryStrozhevsky","html_url":"https://github.com/YuryStrozhevsky","followers_url":"https://api.github.com/users/YuryStrozhevsky/followers","following_url":"https://api.github.com/users/YuryStrozhevsky/following{/other_user}","gists_url":"https://api.github.com/users/YuryStrozhevsky/gists{/gist_id}","starred_url":"https://api.github.com/users/YuryStrozhevsky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/YuryStrozhevsky/subscriptions","organizations_url":"https://api.github.com/users/YuryStrozhevsky/orgs","repos_url":"https://api.github.com/users/YuryStrozhevsky/repos","events_url":"https://api.github.com/users/YuryStrozhevsky/events{/privacy}","received_events_url":"https://api.github.com/users/YuryStrozhevsky/received_events","type":"User","site_admin":false},"created_at":"2018-06-21T06:51:10Z","updated_at":"2018-06-21T06:51:10Z","author_association":"CONTRIBUTOR","body":"Fixed."}}
{"actor":{"display_login":"YuryStrozhevsky"}}