{"record":{"id":"5a6e3b52d5a88bd4","repo":"ruby/ruby","slug":"passphrase-and-passphrase-confirmation-don-t-match","errorCode":null,"errorMessage":"Passphrase and passphrase confirmation don't match","messagePattern":"Passphrase and passphrase confirmation don't match","errorType":"exception","errorClass":"Gem::CommandLineError","httpStatus":null,"severity":"error","filePath":"lib/rubygems/commands/cert_command.rb","lineNumber":174,"sourceCode":"    cert = Gem::Security.create_cert_email(\n      email,\n      key,\n      Gem::Security::ONE_DAY * expiration_length_days\n    )\n\n    Gem::Security.write_certificate cert, \"gem-public_cert.pem\"\n  end\n\n  def build_key # :nodoc:\n    return options[:key] if options[:key]\n\n    passphrase = ask_for_password \"Passphrase for your Private Key:\"\n    say \"\\n\"\n\n    passphrase_confirmation = ask_for_password \"Please repeat the passphrase for your Private Key:\"\n    say \"\\n\"\n\n    raise Gem::CommandLineError,\n          \"Passphrase and passphrase confirmation don't match\" unless passphrase == passphrase_confirmation\n\n    algorithm = options[:key_algorithm] || Gem::Security::DEFAULT_KEY_ALGORITHM\n    key = Gem::Security.create_key(algorithm)\n    key_path = Gem::Security.write_private_key key, \"gem-private_key.pem\", 0o600, passphrase\n\n    [key, key_path]\n  end\n\n  def certificates_matching(filter)\n    return enum_for __method__, filter unless block_given?\n\n    Gem::Security.trusted_certificates.select do |certificate, _|\n      subject = certificate.subject.to_s\n      subject.downcase.index filter\n    end.sort_by do |certificate, _|\n      certificate.subject.to_a.map {|name, data,| [name, data] }\n    end.each do |certificate, path|","sourceCodeStart":156,"sourceCodeEnd":192,"githubUrl":"https://github.com/ruby/ruby/blob/0e5b888e1c355f3f728f2659f085820937dada48/lib/rubygems/commands/cert_command.rb#L156-L192","documentation":"When `gem cert --build` must create a new key (no -K supplied), build_key prompts twice for a passphrase and requires the entries to match; differing entries raise Gem::CommandLineError 'Passphrase and passphrase confirmation don't match'. This is the standard confirm-the-secret pattern - nothing is generated before the check, so re-running is safe.","triggerScenarios":"A typo on the second prompt of `gem cert --build you@example.com`; pasting a long generated passphrase with an extra or missing character; terminal echo oddities when the prompt is driven through a wrapper.","commonSituations":"Interactive signing setup over SSH sessions; automation that tries to drive the two prompts non-interactively; password-manager paste timing issues.","solutions":["Re-run the command and re-enter the passphrase carefully (no key was created)","Generate the key yourself and pass it with -K to avoid prompts entirely","Paste from a password manager for both prompts instead of typing long secrets"],"exampleFix":"# before (interactive typo)\n$ gem cert --build dev@example.com\nPassphrase for your Private Key: ********\nPlease repeat the passphrase for your Private Key: *********\n# ERROR: Passphrase and passphrase confirmation don't match\n\n# after (non-interactive: supply the key, skip the prompt)\nopenssl ecparam -genkey -name secp384r1 -out gem-private_key.pem\ngem cert --build dev@example.com -K gem-private_key.pem","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"attempts = 0\nbegin\n  ok = system('gem', 'cert', '--build', email)\n  raise Gem::CommandLineError, 'gem cert --build failed' unless ok\nrescue Gem::CommandLineError => e\n  retry if e.message.include?(\"confirmation don't match\") && (attempts += 1) < 3\n  raise\nend","preventionTips":["Prefer passing an existing key with -K in automation so no prompt appears","Type passphrases manually rather than piping scripts into the prompt","If the mismatch repeats, suspect the terminal or wrapper mangling input, not your typing"],"tags":["rubygems","cert","passphrase","cli","interactive-prompt"],"backgroundTag":"password-confirmation-mismatch","analyzedSha":"0e5b888e1c355f3f728f2659f085820937dada48","analyzedAt":"2026-08-21T14:25:43.473Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}