Bozhidar Slaveykov 1 년 전
부모
커밋
97a42f93a7
3개의 변경된 파일527개의 추가작업 그리고 161개의 파일을 삭제
  1. 1 0
      web/composer.json
  2. 427 161
      web/composer.lock
  3. 99 0
      web/routes/web.php

+ 1 - 0
web/composer.json

@@ -9,6 +9,7 @@
     "license": "MIT",
     "require": {
         "php": "^8.1",
+        "acmephp/core": "*",
         "calebporzio/sushi": "^2.4",
         "filament/filament": "^3.0-stable",
         "guzzlehttp/guzzle": "^7.2",

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 427 - 161
web/composer.lock


+ 99 - 0
web/routes/web.php

@@ -2,6 +2,20 @@
 
 use Illuminate\Support\Facades\Route;
 
+
+use AcmePhp\Core\Protocol\ExternalAccount;
+use AcmePhp\Core\Http\Base64SafeEncoder;
+use AcmePhp\Core\Http\SecureHttpClientFactory;
+use AcmePhp\Core\Http\ServerErrorHandler;
+use AcmePhp\Ssl\KeyPair;
+use AcmePhp\Ssl\PrivateKey;
+use AcmePhp\Ssl\PublicKey;
+use AcmePhp\Ssl\Parser\KeyParser;
+use AcmePhp\Ssl\Signer\DataSigner;
+use GuzzleHttp\Client as GuzzleHttpClient;
+use AcmePhp\Ssl\Generator\KeyPairGenerator;
+use AcmePhp\Core\AcmeClient;
+
 /*
 |--------------------------------------------------------------------------
 | Web Routes
@@ -23,3 +37,88 @@ Route::get('/', function () {
 
 });
 
+
+Route::get('/testx', function () {
+
+    $storagePath = storage_path('ssl-keys-cache');
+    if (!file_exists($storagePath)) {
+        mkdir($storagePath, 0755, true);
+    }
+
+    $publicKeyPath = $storagePath . '/public-account.pub.pem';
+    $privateKeyPath = $storagePath . '/private-account.pem';
+
+    if (!file_exists($privateKeyPath)) {
+        $keyPairGenerator = new KeyPairGenerator();
+        $keyPair = $keyPairGenerator->generateKeyPair();
+
+        file_put_contents($publicKeyPath, $keyPair->getPublicKey()->getPEM());
+        file_put_contents($privateKeyPath, $keyPair->getPrivateKey()->getPEM());
+    } else {
+        $publicKey = new PublicKey(file_get_contents($publicKeyPath));
+        $privateKey = new PrivateKey(file_get_contents($privateKeyPath));
+
+        $keyPair = new KeyPair($publicKey, $privateKey);
+    }
+
+    $secureHttpClientFactory = new SecureHttpClientFactory(
+        new GuzzleHttpClient(),
+        new Base64SafeEncoder(),
+        new KeyParser(),
+        new DataSigner(),
+        new ServerErrorHandler()
+    );
+
+// $accountKeyPair instance of KeyPair
+    $secureHttpClient = $secureHttpClientFactory->createSecureHttpClient($keyPair);
+
+    $acmeClient = new AcmeClient($secureHttpClient, 'https://acme-staging-v02.api.letsencrypt.org/directory');
+    //$regAccount = $acmeClient->registerAccount('bobi@microweber.com');
+
+    //$authorizationChallenges = $acmeClient->requestAuthorization('basi-qkoto.test.multiweber.com');
+
+//
+//    -domain: "basi-qkoto.test.multiweber.com"
+//    -status: "pending"
+//    -type: "http-01"
+//    -url: "https://acme-staging-v02.api.letsencrypt.org/acme/chall-v3/11864378814/9FukXQ"
+//    -token: "XzOcwy8qddkoewJ-4r4N0NYDyc04WcYAVVOQL_1RxAg"
+//    -payload: "XzOcwy8qddkoewJ-4r4N0NYDyc04WcYAVVOQL_1RxAg.3m75GPL4YOUq0AfwzgzbRQfGWS2vqiVOyQtF4RmedHQ"
+
+//    $authorizationChallenge = \AcmePhp\Core\Protocol\AuthorizationChallenge::fromArray([
+//        'domain' => 'basi-qkoto.test.multiweber.com',
+//        'status' => 'pending',
+//        'type' => 'http-01',
+//        'url' => 'https://acme-staging-v02.api.letsencrypt.org/acme/chall-v3/11864378814/9FukXQ',
+//        'token' => 'XzOcwy8qddkoewJ-4r4N0NYDyc04WcYAVVOQL_1RxAg',
+//        'payload' => 'XzOcwy8qddkoewJ-4r4N0NYDyc04WcYAVVOQL_1RxAg.3m75GPL4YOUq0AfwzgzbRQfGWS2vqiVOyQtF4RmedHQ'
+//    ]);
+//
+//    $check = $acmeClient->challengeAuthorization($authorizationChallenge);
+
+
+
+
+    $dn = new \AcmePhp\Ssl\DistinguishedName('basi-qkoto.test.multiweber.com');
+
+    $keyPairGenerator = new KeyPairGenerator();
+
+// Make a new key pair. We'll keep the private key as our cert key
+    $domainKeyPair = $keyPairGenerator->generateKeyPair();
+
+// This is the private key
+    var_dump($domainKeyPair->getPrivateKey()->getPem());
+
+// Generate CSR
+    $csr = new \AcmePhp\Ssl\CertificateRequest($dn, $domainKeyPair);
+
+
+    $certificateResponse = $acmeClient->requestCertificate('basi-qkoto.test.multiweber.com', $csr);
+
+// This is the certificate (public key)
+    var_dump($certificateResponse->getCertificate()->getPem());
+
+// For Let's Encrypt, you will need the intermediate too
+    var_dump($certificateResponse->getCertificate()->getIssuerCertificate()->getPEM());
+
+});

이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.