2단계: 해지 연결 함수 생성 - Amazon CloudFront

2단계: 해지 연결 함수 생성

KeyValueStore에 대한 인증서 일련 번호를 확인하여 인증서가 해지되었는지 확인하는 연결 함수를 생성합니다.

KeyValueStore에 대해 인증서 일련 번호를 확인하는 연결 함수를 생성합니다.

aws cloudfront create-connection-function \ --name "revocation-control" \ --connection-function-config file://connection-function-config.json \ --connection-function-code file://connection-function-code.txt

구성 파일은 KeyValueStore 연결을 지정합니다.

{ "Runtime": "cloudfront-js-2.0", "Comment": "A function that implements revocation control via KVS", "KeyValueStoreAssociations": { "Quantity": 1, "Items": [ { "KeyValueStoreArn": "arn:aws:cloudfront::account-id:key-value-store/kvs-id" } ] } }

연결 함수 코드는 KeyValueStore에서 해지된 인증서를 확인합니다.

import cf from 'cloudfront'; async function connectionHandler(connection) { const kvsHandle = cf.kvs(); // Get parsed client serial number from client certificate const clientSerialNumber = connection.clientCertInfo.serialNumber; // Check KVS to see if serial number exists as a key const serialNumberExistsInKvs = await kvsHandle.exists(clientSerialNumber); // Deny connection if serial number exists in KVS if (serialNumberExistsInKvs) { console.log("Connection denied - certificate revoked"); return connection.deny(); } // Allow connections that don't exist in kvs console.log("Connection allowed"); return connection.allow(); }