การลงนามโค้ดและการรับรอง
ทำความเข้าใจความสำคัญของการลงนามโค้ดสำหรับ Windows และการรับรองสำหรับ macOS เพื่อสร้างความเชื่อมั่นแก่ผู้ใช้และให้สอดคล้องกับข้อกำหนดด้านความปลอดภัย
การลงนามโค้ดและการรับรอง เป็นบทเรียน Electron Desktop App Development ฟรีบน CoddyKit นี่คือบทเรียนที่ 2 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน Electron Desktop App Development และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส Electron Desktop App Development มีบทเรียนทั้งหมด 4 บทเรียน
บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ
Building Trust with Code Signing
When you distribute your Electron app, users need to trust it. Operating systems like Windows and macOS have built-in security features to protect users from malicious software.
Code signing and notarization are essential steps to prove your app's authenticity and integrity, ensuring users feel safe installing it.
What is Code Signing?
Code signing is like attaching a digital signature to your application. It uses a cryptographic certificate issued by a trusted Certificate Authority (CA).
- Authenticity: Verifies the app comes from you, the publisher.
- Integrity: Confirms the app hasn't been tampered with since you signed it.
If the signature is invalid or altered, the OS will warn the user.
Trust on Windows
On Windows, unsigned applications often trigger security warnings like "Windows protected your PC" (SmartScreen filter).
A valid code signature helps your app pass these checks, giving users confidence and reducing installation friction. It also allows your app to be installed without extra administrator prompts for some operations.
Signing Windows Executables
To sign your Windows Electron app, you'll need a Code Signing Certificate. This is typically a PFX file containing your private key and certificate chain.
Tools like electron-builder simplify this process by letting you specify your certificate details in the configuration.
{
"build": {
"win": {
"target": "nsis",
"signingHashAlgorithms": ["sha256"],
"signAndEditExecutable": true
},
"cscKeyPassword": "your-cert-password",
"cscInstallerPassword": "your-cert-password",
"cscLink": "path/to/your/certificate.pfx"
}
}Time-Stamping Your Signature
When code signing, it's crucial to also time-stamp your signature. This ensures that even if your signing certificate expires, the signature remains valid because it was signed when the certificate was active.
Most signing tools, including electron-builder, can automatically add a time-stamp server URL to your signing process.
macOS Notarization Explained
For macOS, Apple introduced Notarization as an additional security check. It's an automated service that scans your app for malicious content and code signature issues.
Think of it as Apple giving your app a "seal of approval" before it can run smoothly on macOS Catalina and later.
Meeting Apple's Gatekeeper
macOS's security feature, Gatekeeper, blocks unsigned or unnotarized apps from running by default. Users will see a warning that the app "cannot be opened because the developer cannot be verified."
Notarization allows your app to pass Gatekeeper checks without annoying users or requiring them to bypass security settings manually.
Getting Ready for Notarization
To notarize your Electron app, you need:
- An Apple Developer ID.
- An app-specific password for your Apple ID.
- Your app must be signed with a Developer ID Application certificate.
- Hardened Runtime enabled (a security feature).
electron-builder handles most of these configurations for you.
Notarizing with electron-builder
electron-builder simplifies the notarization process. You configure your Apple ID credentials and it handles uploading your app to Apple's notarization service.
It waits for the notarization to complete and then "staples" the notarization ticket to your app bundle.
{
"build": {
"mac": {
"hardenedRuntime": true,
"gatekeeperAssess": false,
"entitlementsInherit": "build/entitlements.mac.plist",
"entitlements": "build/entitlements.mac.plist"
},
"afterSign": "electron-builder-notarize"
}
}Secure & Automated Signing
Always keep your signing certificates and private keys secure. Treat them like sensitive passwords.
Integrate code signing and notarization into your Continuous Integration/Continuous Deployment (CI/CD) pipeline to automate the process and ensure every build is properly signed and notarized.
Check Your Knowledge
Which statements accurately describe the purpose or requirements of code signing and macOS notarization?
Recap: Trust & Security
In this lesson, we learned about the critical role of code signing for Windows and notarization for macOS in distributing your Electron applications.
These processes build user trust, ensure app integrity, and help your app run smoothly on target operating systems by satisfying their built-in security requirements.
คำถามที่พบบ่อย
บทเรียน “การลงนามโค้ดและการรับรอง” ฟรีหรือไม่
ใช่ — ข้อความเต็มของ “การลงนามโค้ดและการรับรอง” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Electron Desktop App Development ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Electron Desktop App Development มีบทเรียนทั้งหมด 4 บทเรียน
คุณจะเรียนรู้อะไรในบทเรียน “การลงนามโค้ดและการรับรอง”
ทำความเข้าใจความสำคัญของการลงนามโค้ดสำหรับ Windows และการรับรองสำหรับ macOS เพื่อสร้างความเชื่อมั่นแก่ผู้ใช้และให้สอดคล้องกับข้อกำหนดด้านความปลอดภัย คุณปฏิบัติ Electron Desktop App Development ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน
คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Electron Desktop App Development หรือไม่
ไม่จำเป็นต้องมีประสบการณ์มาก่อน Electron Desktop App Development บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 2 จากทั้งหมด 4 บทเรียน
บทเรียน “การลงนามโค้ดและการรับรอง” ใช้เวลานานแค่ไหน
บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย
ฉันเขียนและรันโค้ดในบทเรียน Electron Desktop App Development นี้ได้ไหม
ได้ บทเรียน Electron Desktop App Development ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ
บทเรียนทั้งหมดในหลักสูตรนี้
- การจัดแพ็กเกจข้ามแพลตฟอร์ม
- การลงนามโค้ดและการรับรอง
- การเผยแพร่ผ่านร้านค้าแอป
- การทำรุ่นเผยแพร่อัตโนมัติด้วย CI/CD