update
This commit is contained in:
parent
6288910fad
commit
97a42f93a7
3 changed files with 1484 additions and 812 deletions
|
@ -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",
|
||||
|
|
2196
web/composer.lock
generated
2196
web/composer.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -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());
|
||||
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue